]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
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. | |
c4029823 | 13 | * |
28f540f4 RM |
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. | |
c4029823 | 17 | * |
28f540f4 RM |
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. | |
c4029823 | 21 | * |
28f540f4 RM |
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. | |
c4029823 | 25 | * |
28f540f4 RM |
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. | |
c4029823 | 29 | * |
28f540f4 RM |
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 | */ | |
e7fd8a39 | 39 | #include <errno.h> |
28f540f4 | 40 | #include <rpc/rpc.h> |
28f540f4 | 41 | |
1f07e617 UD |
42 | static int svc_stop = 0; |
43 | ||
44 | /* This function can be used as a signal handler to terminate the | |
45 | server loop. */ | |
46 | void | |
47 | svc_exit (void) | |
48 | { | |
49 | svc_stop = 1; | |
50 | } | |
51 | ||
28f540f4 | 52 | void |
e7fd8a39 | 53 | svc_run (void) |
28f540f4 RM |
54 | { |
55 | #ifdef FD_SETSIZE | |
e7fd8a39 | 56 | fd_set readfds; |
28f540f4 | 57 | #else |
e7fd8a39 | 58 | int readfds; |
28f540f4 | 59 | #endif /* def FD_SETSIZE */ |
28f540f4 | 60 | |
1f07e617 UD |
61 | svc_stop = 0; |
62 | ||
e7fd8a39 UD |
63 | for (;;) |
64 | { | |
1f07e617 UD |
65 | if (svc_stop) |
66 | return; | |
67 | ||
28f540f4 | 68 | #ifdef FD_SETSIZE |
e7fd8a39 | 69 | readfds = svc_fdset; |
28f540f4 | 70 | #else |
e7fd8a39 | 71 | readfds = svc_fds; |
28f540f4 | 72 | #endif /* def FD_SETSIZE */ |
50304ef0 UD |
73 | switch (__select (_rpc_dtablesize (), &readfds, (fd_set *)NULL, |
74 | (fd_set *)NULL, (struct timeval *) 0)) | |
e7fd8a39 UD |
75 | { |
76 | case -1: | |
77 | if (errno == EINTR) | |
78 | { | |
79 | continue; | |
80 | } | |
81 | perror (_("svc_run: - select failed")); | |
82 | return; | |
83 | case 0: | |
84 | continue; | |
85 | default: | |
86 | svc_getreqset (&readfds); | |
28f540f4 | 87 | } |
e7fd8a39 | 88 | } |
28f540f4 | 89 | } |