Revision 1.3 |
Revision 1.5 |
Line 6089 |
Line 6089 |
return pth_accept_ev(s, addr, addrlen, NULL); }
|
return pth_accept_ev(s, addr, addrlen, NULL); }
|
/* Pth variant of accept(2) with extra events */
|
/*
|
|
* Pth variant of accept(2) with extra events; hacked up for CoW to hardcode
* everything to blocking semantics; this is bad in general, but since CoW
* doesn't use NBIO semantics anywhere, this allows us to fork multiple
* processes and have them all accept() on the same socket.
*/
|
int pth_accept_ev(int s, struct sockaddr *addr, socklen_t *addrlen, pth_event_t ev_extra) { pth_event_t ev;
|
int pth_accept_ev(int s, struct sockaddr *addr, socklen_t *addrlen, pth_event_t ev_extra) { pth_event_t ev;
|
Line 6112 |
Line 6117 |
ev = NULL; while ((rv = pth_sc(accept)(s, addr, addrlen)) == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
|
ev = NULL; while ((rv = pth_sc(accept)(s, addr, addrlen)) == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
|
&& fdmode != PTH_FDMODE_NONBLOCK) {
|
/* && fdmode != PTH_FDMODE_NONBLOCK */ ) {
|
/* do lazy event allocation */ if (ev == NULL) { ev = pth_event(PTH_EVENT_FD|PTH_UNTIL_FD_READABLE|PTH_MODE_STATIC, &ev_key, s);
|
/* do lazy event allocation */ if (ev == NULL) { ev = pth_event(PTH_EVENT_FD|PTH_UNTIL_FD_READABLE|PTH_MODE_STATIC, &ev_key, s);
|
Line 6121 |
Line 6126 |
} /* wait until accept has a chance */ pth_wait(ev);
|
} /* wait until accept has a chance */ pth_wait(ev);
|
|
|
/* check for the extra events */ if (ev_extra != NULL) { pth_event_isolate(ev);
|
/* check for the extra events */ if (ev_extra != NULL) { pth_event_isolate(ev);
|
Line 6133 |
Line 6139 |
/* restore filedescriptor mode */ pth_shield {
|
/* restore filedescriptor mode */ pth_shield {
|
pth_fdmode(s, fdmode);
|
pth_fdmode(s, PTH_FDMODE_BLOCK);
|
if (rv != -1)
|
if (rv != -1)
|
pth_fdmode(rv, fdmode);
|
pth_fdmode(rv, PTH_FDMODE_BLOCK);
|
} pth_debug2("pth_accept_ev: leave to thread \"%s\"", pth_current->name);
|
} pth_debug2("pth_accept_ev: leave to thread \"%s\"", pth_current->name);
|
Line 7693 |
Line 7699 |
}
|
}
|