diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-05-21 00:01:07 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-05-21 00:01:07 +0000 |
commit | 402a46171b23e0e2512dadf5fadef4d57757cbcb (patch) | |
tree | 23a9425c749f9cd45f68012d1cad65c998ad710b /sunrpc | |
parent | ae4b002f02cf91ae7b46caa59285352badbe295b (diff) |
(svc_exit): New, defined.
(svc_run): Test for svc_stop variable.
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/svc_run.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c index 45ea4008bc..021484d864 100644 --- a/sunrpc/svc_run.c +++ b/sunrpc/svc_run.c @@ -36,39 +36,54 @@ static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; * This is the rpc server side idle loop * Wait for input, call server program. */ +#include <errno.h> #include <rpc/rpc.h> -#include <sys/errno.h> + +static int svc_stop = 0; + +/* This function can be used as a signal handler to terminate the + server loop. */ +void +svc_exit (void) +{ + svc_stop = 1; +} void -svc_run() +svc_run (void) { #ifdef FD_SETSIZE - fd_set readfds; + fd_set readfds; #else - int readfds; + int readfds; #endif /* def FD_SETSIZE */ -#ifndef errno - extern int errno; -#endif - for (;;) { + svc_stop = 0; + + for (;;) + { + if (svc_stop) + return; + #ifdef FD_SETSIZE - readfds = svc_fdset; + readfds = svc_fdset; #else - readfds = svc_fds; + readfds = svc_fds; #endif /* def FD_SETSIZE */ - switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0, - (struct timeval *)0)) { - case -1: - if (errno == EINTR) { - continue; - } - perror("svc_run: - select failed"); - return; - case 0: - continue; - default: - svc_getreqset(&readfds); - } + switch (select (_rpc_dtablesize (), &readfds, (fd_set *)NULL, + (fd_set *)NULL, (struct timeval *) 0)) + { + case -1: + if (errno == EINTR) + { + continue; + } + perror (_("svc_run: - select failed")); + return; + case 0: + continue; + default: + svc_getreqset (&readfds); } + } } |