home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / rpc / svc_run.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-01  |  2.3 KB  |  98 lines

  1. /* @(#)svc_run.c    2.1 88/07/29 4.0 RPCSRC */
  2. #if !defined(lint) && defined(SCCSIDS)
  3. static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
  4. #endif
  5.  
  6. /*
  7.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  8.  * unrestricted use provided that this legend is included on all tape
  9.  * media and as a part of the software program in whole or part.  Users
  10.  * may copy or modify Sun RPC without charge, but are not authorized
  11.  * to license or distribute it to anyone else except as part of a product or
  12.  * program developed by the user.
  13.  * 
  14.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  15.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  16.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  17.  * 
  18.  * Sun RPC is provided with no support and without any obligation on the
  19.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  20.  * modification or enhancement.
  21.  * 
  22.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  23.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  24.  * OR ANY PART THEREOF.
  25.  * 
  26.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  27.  * or profits or other special, indirect and consequential damages, even if
  28.  * Sun has been advised of the possibility of such damages.
  29.  * 
  30.  * Sun Microsystems, Inc.
  31.  * 2550 Garcia Avenue
  32.  * Mountain View, California  94043
  33.  */
  34.  
  35. /*
  36.  * This is the rpc server side idle loop
  37.  * Wait for input, call server program.
  38.  */
  39. #include <rpc/rpc.h>
  40. #include <sys/errno.h>
  41.  
  42. #if NLS
  43. #include "nl_types.h"
  44. #endif
  45.  
  46. static int svc_stop = 0;
  47.  
  48. void svc_exit (void)
  49. {
  50.   svc_stop = 1;
  51. }
  52.  
  53. void
  54. svc_run()
  55. {
  56. #ifdef FD_SETSIZE
  57.     fd_set readfds;
  58. #else
  59.       int readfds;
  60. #endif /* def FD_SETSIZE */
  61.     extern int errno;
  62.  
  63. #if NLS
  64.     libc_nls_init();
  65. #endif
  66.  
  67.     svc_stop = 0;
  68.  
  69.     for (;;) {
  70.         if (svc_stop)
  71.             return;
  72. #ifdef FD_SETSIZE
  73.         readfds = svc_fdset;
  74. #else
  75.         readfds = svc_fds;
  76. #endif /* def FD_SETSIZE */
  77.         switch (select(_rpc_dtablesize(), &readfds, (void *)0, (void *)0,
  78.                    (struct timeval *)0)) {
  79.         case -1:
  80.             if (errno == EINTR) {
  81.                 continue;
  82.             }
  83. #if NLS
  84.             perror(catgets(_libc_cat, RpcMiscSet,
  85.                        RpcMiscSelectFailed,
  86.                     "svc_run: - select failed"));
  87. #else
  88.             perror("svc_run: - select failed");
  89. #endif
  90.             return;
  91.         case 0:
  92.             continue;
  93.         default:
  94.             svc_getreqset(&readfds);
  95.         }
  96.     }
  97. }
  98.