Revision 1.4 |
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); if (ev_extra != NULL) pth_event_concat(ev, ev_extra, NULL); }
|
/* do lazy event allocation */ if (ev == NULL) { ev = pth_event(PTH_EVENT_FD|PTH_UNTIL_FD_READABLE|PTH_MODE_STATIC, &ev_key, s); if (ev_extra != NULL) pth_event_concat(ev, ev_extra, NULL); }
|
/*
|
/* wait until accept has a chance */
|
* wait until accept has a chance; must put socket back in original
* state before waiting so that other calls to pth_accept() won't
* unexpectedly be non-blocking
*/
pth_fdmode(s, fdmode);
|
|
pth_wait(ev);
|
pth_wait(ev);
|
if (pth_fdmode(s, PTH_FDMODE_NONBLOCK) == PTH_FDMODE_ERROR)
|
|
return pth_error(-1, EBADF);
|
|
/* 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 6140 |
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 7700 |
Line 7699 |
}
|
}
|