From: Ulrich Drepper Date: Wed, 21 May 1997 00:01:07 +0000 (+0000) Subject: (svc_exit): New, defined. X-Git-Tag: cvs/libc-2_0_4~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=402a46171b23e0e2512dadf5fadef4d57757cbcb;p=thirdparty%2Fglibc.git (svc_exit): New, defined. (svc_run): Test for svc_stop variable. --- diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c index 45ea4008bca..021484d8645 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 #include -#include + +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); } + } }