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