]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(svc_exit): New, defined.
authorUlrich Drepper <drepper@redhat.com>
Wed, 21 May 1997 00:01:07 +0000 (00:01 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 21 May 1997 00:01:07 +0000 (00:01 +0000)
(svc_run): Test for svc_stop variable.

sunrpc/svc_run.c

index 45ea4008bca051ab6c67025e48b57424cf979110..021484d864542258a99bafe7d9f940503e549b2f 100644 (file)
@@ -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);
        }
+    }
 }