ReactOS  0.4.14-dev-49-gfb4591c
SAcceptA.c
Go to the documentation of this file.
1 #include "syshdrs.h"
2 
3 #ifndef NO_SIGNALS
4 extern volatile Sjmp_buf gNetTimeoutJmp;
5 extern volatile Sjmp_buf gPipeJmp;
6 #endif
7 
8 int
9 SAcceptA(int sfd, struct sockaddr_in *const addr, int tlen)
10 {
11  int result;
12 #ifndef NO_SIGNALS
13  vsio_sigproc_t sigalrm, sigpipe;
14 #endif
15  size_t size;
16 
17  if (tlen < 0) {
18  errno = 0;
19  for (;;) {
20  size = sizeof(struct sockaddr_in);
21  result = accept(sfd, (struct sockaddr *) addr, (int *) &size);
22  if ((result >= 0) || (errno != EINTR))
23  return (result);
24  }
25  }
26 #ifndef NO_SIGNALS
27  if (SSetjmp(gNetTimeoutJmp) != 0) {
28  alarm(0);
29  (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
30  (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
31  errno = ETIMEDOUT;
32  return (kTimeoutErr);
33  }
34 
35  sigalrm = (vsio_sigproc_t) SSignal(SIGALRM, SIOHandler);
36  sigpipe = (vsio_sigproc_t) SSignal(SIGPIPE, SIG_IGN);
37  alarm((unsigned int) tlen);
38 
39  errno = 0;
40  do {
41  size = sizeof(struct sockaddr_in);
42  result = accept(sfd, (struct sockaddr *) addr, (int *) &size);
43  } while ((result < 0) && (errno == EINTR));
44 
45  alarm(0);
46  (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
47  (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
48  return (result);
49 #else
50  return (-1);
51 #endif
52 } /* SAcceptA */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
#define EINTR
Definition: acclib.h:80
int errno
#define Sjmp_buf
Definition: sio.h:41
#define kTimeoutErr
Definition: sio.h:58
GLsizeiptr size
Definition: glext.h:5919
int SAcceptA(int sfd, struct sockaddr_in *const addr, int tlen)
Definition: SAcceptA.c:9
#define SIGPIPE
Definition: signal.h:35
#define SSetjmp(a)
Definition: sio.h:39
GLenum const GLvoid * addr
Definition: glext.h:9621
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
#define ETIMEDOUT
Definition: errno.h:121
#define SIG_IGN
Definition: signal.h:48
GLuint64EXT * result
Definition: glext.h:11304
void(* sio_sigproc_t)(int)
Definition: sio.h:123
void SIOHandler(int)