Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/rpcbind/rpcb_svc_com.c
Show First 20 Lines • Show All 1,095 Lines • ▼ Show 20 Lines | |||||
#define MASKVAL (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND) | #define MASKVAL (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND) | ||||
extern bool_t __svc_clean_idle(fd_set *, int, bool_t); | extern bool_t __svc_clean_idle(fd_set *, int, bool_t); | ||||
void | void | ||||
my_svc_run(void) | my_svc_run(void) | ||||
{ | { | ||||
size_t nfds; | size_t nfds; | ||||
struct pollfd pollfds[FD_SETSIZE]; | struct pollfd pollfds[FD_SETSIZE + 1]; | ||||
int poll_ret, check_ret; | int poll_ret, check_ret; | ||||
int n; | int n; | ||||
#ifdef SVC_RUN_DEBUG | #ifdef SVC_RUN_DEBUG | ||||
int i; | int i; | ||||
#endif | #endif | ||||
register struct pollfd *p; | register struct pollfd *p; | ||||
fd_set cleanfds; | fd_set cleanfds; | ||||
for (;;) { | for (;;) { | ||||
p = pollfds; | p = pollfds; | ||||
p->fd = terminate_rfd; | |||||
p->events = MASKVAL; | |||||
p++; | |||||
for (n = 0; n <= svc_maxfd; n++) { | for (n = 0; n <= svc_maxfd; n++) { | ||||
if (FD_ISSET(n, &svc_fdset)) { | if (FD_ISSET(n, &svc_fdset)) { | ||||
p->fd = n; | p->fd = n; | ||||
p->events = MASKVAL; | p->events = MASKVAL; | ||||
p++; | p++; | ||||
} | } | ||||
} | } | ||||
nfds = p - pollfds; | nfds = p - pollfds; | ||||
poll_ret = 0; | poll_ret = 0; | ||||
#ifdef SVC_RUN_DEBUG | #ifdef SVC_RUN_DEBUG | ||||
if (debugging) { | if (debugging) { | ||||
fprintf(stderr, "polling for read on fd < "); | fprintf(stderr, "polling for read on fd < "); | ||||
for (i = 0, p = pollfds; i < nfds; i++, p++) | for (i = 0, p = pollfds; i < nfds; i++, p++) | ||||
if (p->events) | if (p->events) | ||||
fprintf(stderr, "%d ", p->fd); | fprintf(stderr, "%d ", p->fd); | ||||
fprintf(stderr, ">\n"); | fprintf(stderr, ">\n"); | ||||
} | } | ||||
#endif | #endif | ||||
switch (poll_ret = poll(pollfds, nfds, 30 * 1000)) { | poll_ret = poll(pollfds, nfds, 30 * 1000); | ||||
case -1: | |||||
/* | |||||
* We ignore all errors, continuing with the assumption | |||||
* that it was set by the signal handlers (or any | |||||
* other outside event) and not caused by poll(). | |||||
*/ | |||||
if (doterminate != 0) { | if (doterminate != 0) { | ||||
close(rpcbindlockfd); | close(rpcbindlockfd); | ||||
#ifdef WARMSTART | #ifdef WARMSTART | ||||
syslog(LOG_ERR, | syslog(LOG_ERR, | ||||
"rpcbind terminating on signal %d. Restart with \"rpcbind -w\"", | "rpcbind terminating on signal %d. Restart with \"rpcbind -w\"", | ||||
(int)doterminate); | (int)doterminate); | ||||
write_warmstart(); /* Dump yourself */ | write_warmstart(); /* Dump yourself */ | ||||
#endif | #endif | ||||
exit(2); | exit(2); | ||||
} | } | ||||
switch (poll_ret) { | |||||
case -1: | |||||
/* | |||||
* We ignore all errors, continuing with the assumption | |||||
* that it was set by the signal handlers (or any | |||||
* other outside event) and not caused by poll(). | |||||
*/ | |||||
case 0: | case 0: | ||||
cleanfds = svc_fdset; | cleanfds = svc_fdset; | ||||
__svc_clean_idle(&cleanfds, 30, FALSE); | __svc_clean_idle(&cleanfds, 30, FALSE); | ||||
continue; | continue; | ||||
default: | default: | ||||
#ifdef SVC_RUN_DEBUG | #ifdef SVC_RUN_DEBUG | ||||
if (debugging) { | if (debugging) { | ||||
fprintf(stderr, "poll returned read fds < "); | fprintf(stderr, "poll returned read fds < "); | ||||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |