Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nfs-utils / utils / mountd / svc_run.c
blob422e839c171176638e66c32b53fa2af8a63f3886
1 /*
2 * Copyright (C) 1984 Sun Microsystems, Inc.
3 * Based on svc_run.c from statd which claimed:
4 * Modified by Jeffrey A. Uphoff, 1995, 1997-1999.
5 * Modified by Olaf Kirch, 1996.
7 */
9 /*
10 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
11 * unrestricted use provided that this legend is included on all tape
12 * media and as a part of the software program in whole or part. Users
13 * may copy or modify Sun RPC without charge, but are not authorized
14 * to license or distribute it to anyone else except as part of a product or
15 * program developed by the user.
17 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
18 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
21 * Sun RPC is provided with no support and without any obligation on the
22 * part of Sun Microsystems, Inc. to assist in its use, correction,
23 * modification or enhancement.
25 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
26 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
27 * OR ANY PART THEREOF.
29 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
30 * or profits or other special, indirect and consequential damages, even if
31 * Sun has been advised of the possibility of such damages.
33 * Sun Microsystems, Inc.
34 * 2550 Garcia Avenue
35 * Mountain View, California 94043
38 /*
39 * Allow svc_run to listen to other file descriptors as well
42 /*
43 * This is the RPC server side idle loop.
44 * Wait for input, call server program.
47 #ifdef HAVE_CONFIG_H
48 #include <config.h>
49 #endif
51 #include <sys/types.h>
52 #include <rpc/rpc.h>
53 #include "xlog.h"
54 #include <errno.h>
55 #include <time.h>
57 void cache_set_fds(fd_set *fdset);
58 int cache_process_req(fd_set *readfds);
60 #if LONG_MAX != INT_MAX
61 /* bug in glibc 2.3.6 and earlier, we need
62 * our own svc_getreqset
64 static void
65 my_svc_getreqset (fd_set *readfds)
67 fd_mask mask;
68 fd_mask *maskp;
69 int setsize;
70 int sock;
71 int bit;
73 setsize = _rpc_dtablesize ();
74 if (setsize > FD_SETSIZE)
75 setsize = FD_SETSIZE;
76 maskp = readfds->fds_bits;
77 for (sock = 0; sock < setsize; sock += NFDBITS)
78 for (mask = *maskp++;
79 (bit = ffsl (mask));
80 mask ^= (1L << (bit - 1)))
81 svc_getreq_common (sock + bit - 1);
83 #define svc_getreqset my_svc_getreqset
85 #endif
88 * The heart of the server. A crib from libc for the most part...
90 void
91 my_svc_run(void)
93 fd_set readfds;
94 int selret;
96 for (;;) {
98 readfds = svc_fdset;
99 cache_set_fds(&readfds);
101 selret = select(FD_SETSIZE, &readfds,
102 (void *) 0, (void *) 0, (struct timeval *) 0);
105 switch (selret) {
106 case -1:
107 if (errno == EINTR || errno == ECONNREFUSED
108 || errno == ENETUNREACH || errno == EHOSTUNREACH)
109 continue;
110 xlog(L_ERROR, "my_svc_run() - select: %m");
111 return;
113 default:
114 selret -= cache_process_req(&readfds);
115 if (selret)
116 svc_getreqset(&readfds);