void svc_run() { fd_set *fds; for (;;) { if (__svc_fdset) { int bytes = sizeof (fd_set); fds = (fd_set *)malloc(bytes); memcpy(fds, __svc_fdset, bytes); } else fds = NULL; switch (select(svc_maxfd + 1, fds, NULL, NULL, (struct timeval *)0)) { case -1: if (errno == EINTR) { if (fds) free(fds); continue; } perror("svc_run: - select failed"); if (fds) free(fds); return; case 0: if (fds) free(fds); continue; default: /* if fds == NULL, select() can't return a result */ svc_getreqset2(fds, svc_maxfd + 1); free(fds); } } }
void mountd_svc_run(void) { fd_set *fds = NULL; int fds_size = 0; extern fd_set *__svc_fdset; extern int __svc_fdsetsize; for (;;) { if (gothup) { get_exportlist(); gothup = 0; } if (gotterm) { (void) clnt_broadcast(RPCPROG_MNT, RPCMNT_VER1, RPCMNT_UMNTALL, xdr_void, (caddr_t)0, xdr_void, (caddr_t)0, umntall_each); exit(0); } if (__svc_fdset) { int bytes = howmany(__svc_fdsetsize, NFDBITS) * sizeof(fd_mask); if (fds_size != __svc_fdsetsize) { if (fds) free(fds); fds = (fd_set *)malloc(bytes); /* XXX */ fds_size = __svc_fdsetsize; } memcpy(fds, __svc_fdset, bytes); } else { if (fds) free(fds); fds = NULL; } switch (select(svc_maxfd+1, fds, 0, 0, (struct timeval *)0)) { case -1: if (errno == EINTR) break; perror("mountd_svc_run: - select failed"); if (fds) free(fds); return; case 0: break; default: svc_getreqset2(fds, svc_maxfd+1); break; } } }
void svc_getreqset(fd_set *readfds) { svc_getreqset2(readfds, FD_SETSIZE); }