ReactOS 0.4.16-dev-122-g325d74c
USendto.c
Go to the documentation of this file.
1#include "syshdrs.h"
2
3#if !defined(NO_UNIX_DOMAIN_SOCKETS) && !defined(NO_SIGNALS)
4
5extern volatile Sjmp_buf gNetTimeoutJmp;
6extern volatile Sjmp_buf gPipeJmp;
7
8int
9USendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr_un *const toAddr, int ualen, int tlen)
10{
11 int nwrote, tleft;
12 vsio_sigproc_t sigalrm, sigpipe;
13 time_t done, now;
14
15 if (SSetjmp(gNetTimeoutJmp) != 0) {
16 alarm(0);
17 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
18 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
20 return (kTimeoutErr);
21 }
22
23 if (SSetjmp(gPipeJmp) != 0) {
24 alarm(0);
25 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
26 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
27 errno = EPIPE;
28 return (kBrokenPipeErr);
29 }
30
31 sigalrm = (vsio_sigproc_t) SSignal(SIGALRM, SIOHandler);
33
34 time(&now);
35 done = now + tlen;
36 tleft = (int) (done - now);
37 forever {
38 (void) alarm((unsigned int) tleft);
39 nwrote = sendto(sfd, buf, size, fl,
40 (struct sockaddr *) toAddr, ualen);
41 (void) alarm(0);
42 if (nwrote >= 0)
43 break;
44 if (errno != EINTR)
45 break; /* Fatal error. */
46 errno = 0;
47 time(&now);
48 tleft = (int) (done - now);
49 if (tleft < 1) {
50 nwrote = kTimeoutErr;
52 break;
53 }
54 }
55
56 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
57 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
58
59 return (nwrote);
60} /* USendto */
61
62#endif
63
#define EINTR
Definition: acclib.h:80
#define EPIPE
Definition: acclib.h:91
#define SIGPIPE
Definition: signal.h:35
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
#define ETIMEDOUT
Definition: errno.h:121
__kernel_time_t time_t
Definition: linux.h:252
time_t now
Definition: finger.c:65
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__u16 time
Definition: mkdosfs.c:8
#define kBrokenPipeErr
Definition: sio.h:59
void SIOHandler(int)
#define SSetjmp(a)
Definition: sio.h:39
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
#define Sjmp_buf
Definition: sio.h:41
#define kTimeoutErr
Definition: sio.h:58
void(* sio_sigproc_t)(int)
Definition: sio.h:123
#define forever
Definition: ncftp.h:73
#define errno
Definition: errno.h:18
int USendto(int, const char *const, size_t, int, const struct sockaddr_un *const, int, int)
_In_ FLONG fl
Definition: winddi.h:1279