Debian Codegraph @

extra/tirpc/libtirpc-1.3.5/src/svc.c

raw symbols SCIP
1
2 /*
3 * Copyright (c) 2009, Sun Microsystems, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * - Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * - Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * - Neither the name of Sun Microsystems, Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31 * svc.c, Server-side remote procedure call interface.
32 *
33 * There are two sets of procedures here. The xprt routines are
34 * for handling transport handles. The svc routines handle the
35 * list of service routines.
36 *
37 * Copyright (C) 1984, Sun Microsystems, Inc.
38 */
39 #include <pthread.h>
40
41 #include <reentrant.h>
42 #include <sys/types.h>
43 #include <poll.h>
44 #include <assert.h>
45 #include <errno.h>
46 #include <stdlib.h>
47 #include <string.h>
48
49 #include <rpc/rpc.h>
50 #ifdef PORTMAP
51 #include <rpc/pmap_clnt.h>
52 #endif /* PORTMAP */
53
54 #include "rpc_com.h"
55
56 #define RQCRED_SIZE 400 /* this size is excessive */
57
58 #define max(a, b) (a > b ? a : b)
59
60 SVCXPRT **__svc_xports;
61 int __svc_maxrec;
62
63 /*
64 * The services list
65 * Each entry represents a set of procedures (an rpc program).
66 * The dispatch routine takes request structs and runs the
67 * apropriate procedure.
68 */
69 static struct svc_callout
70 {
71 struct svc_callout *sc_next;
72 rpcprog_t sc_prog;
73 rpcvers_t sc_vers;
74 char *sc_netid;
75 void (*sc_dispatch) (struct svc_req *, SVCXPRT *);
76 } *svc_head;
77
78 extern rwlock_t svc_lock;
79 extern rwlock_t svc_fd_lock;
80
81 static struct svc_callout *svc_find (rpcprog_t, rpcvers_t,
82 struct svc_callout **, char *);
83 static void __xprt_do_unregister (SVCXPRT * xprt, bool_t dolock);
84
85 /* *************** SVCXPRT related stuff **************** */
86
87 /*
88 * Activate a transport handle.
89 */
90 void
91 xprt_register (xprt)
92 SVCXPRT *xprt;
93 {
94 int sock;
95
96 assert (xprt != NULL);
97
98 sock = xprt->xp_fd;
99
100 rwlock_wrlock (&svc_fd_lock);
101 if (__svc_xports == NULL)
102 {
103 __svc_xports = (SVCXPRT **) calloc (_rpc_dtablesize(), sizeof (SVCXPRT *));
104 if (__svc_xports == NULL)
105 goto unlock;
106 }
107 if (sock < _rpc_dtablesize())
108 {
109 int i;
110 struct pollfd *new_svc_pollfd;
111
112 __svc_xports[sock] = xprt;
113 if (sock < FD_SETSIZE)
114 {
115 FD_SET (sock, &svc_fdset);
116 svc_maxfd = max (svc_maxfd, sock);
117 }
118
119 /* Check if we have an empty slot */
120 for (i = 0; i < svc_max_pollfd; ++i)
121 if (svc_pollfd[i].fd == -1)
122 {
123 svc_pollfd[i].fd = sock;
124 svc_pollfd[i].events = (POLLIN | POLLPRI |
125 POLLRDNORM | POLLRDBAND);
126 goto unlock;
127 }
128
129 new_svc_pollfd = (struct pollfd *) realloc (svc_pollfd,
130 sizeof (struct pollfd)
131 * (svc_max_pollfd + 1));
132 if (new_svc_pollfd == NULL) /* Out of memory */
133 goto unlock;
134 svc_pollfd = new_svc_pollfd;
135 ++svc_max_pollfd;
136
137 svc_pollfd[svc_max_pollfd - 1].fd = sock;
138 svc_pollfd[svc_max_pollfd - 1].events = (POLLIN | POLLPRI |
139 POLLRDNORM | POLLRDBAND);
140 }
141 unlock:
142 rwlock_unlock (&svc_fd_lock);
143 }
144
145 void
146 xprt_unregister (SVCXPRT * xprt)
147 {
148 __xprt_do_unregister (xprt, TRUE);
149 }
150
151 void
152 __xprt_unregister_unlocked (SVCXPRT * xprt)
153 {
154 __xprt_do_unregister (xprt, FALSE);
155 }
156
157 /*
158 * De-activate a transport handle.
159 */
160 static void
161 __xprt_do_unregister (xprt, dolock)
162 SVCXPRT *xprt;
163 bool_t dolock;
164 {
165 int sock;
166
167 assert (xprt != NULL);
168
169 sock = xprt->xp_fd;
170
171 if (dolock)
172 rwlock_wrlock (&svc_fd_lock);
173 if ((sock < _rpc_dtablesize() ) && (__svc_xports[sock] == xprt))
174 {
175 int i;
176
177 __svc_xports[sock] = NULL;
178 if (sock < FD_SETSIZE)
179 {
180 FD_CLR (sock, &svc_fdset);
181 if (sock >= svc_maxfd)
182 {
183 for (svc_maxfd--; svc_maxfd >= 0; svc_maxfd--)
184 if (__svc_xports[svc_maxfd])
185 break;
186 }
187 }
188
189 for (i = 0; i < svc_max_pollfd; ++i)
190 if (svc_pollfd[i].fd == sock)
191 svc_pollfd[i].fd = -1;
192 }
193 if (dolock)
194 rwlock_unlock (&svc_fd_lock);
195 }
196
197 int
198 svc_open_fds()
199 {
200 int ix;
201 int nfds = 0;
202
203 rwlock_rdlock (&svc_fd_lock);
204 for (ix = 0; ix < svc_max_pollfd; ++ix) {
205 if (svc_pollfd[ix].fd != -1)
206 nfds++;
207 }
208 rwlock_unlock (&svc_fd_lock);
209 return (nfds);
210 }
211
212 /*
213 * Add a service program to the callout list.
214 * The dispatch routine will be called when a rpc request for this
215 * program number comes in.
216 */
217 bool_t
218 svc_reg (xprt, prog, vers, dispatch, nconf)
219 SVCXPRT *xprt;
220 const rpcprog_t prog;
221 const rpcvers_t vers;
222 void (*dispatch) (struct svc_req *, SVCXPRT *);
223 const struct netconfig *nconf;
224 {
225 bool_t dummy;
226 struct svc_callout *prev;
227 struct svc_callout *s;
228 struct netconfig *tnconf;
229 char *netid = NULL;
230 int flag = 0;
231
232 /* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */
233 if (xprt->xp_netid)
234 {
235 netid = strdup (xprt->xp_netid);
236 flag = 1;
237 }
238 else if (nconf && nconf->nc_netid)
239 {
240 netid = strdup (nconf->nc_netid);
241 flag = 1;
242 }
243 else if ((tnconf = __rpcgettp (xprt->xp_fd)) != NULL)
244 {
245 netid = strdup (tnconf->nc_netid);
246 flag = 1;
247 freenetconfigent (tnconf);
248 } /* must have been created with svc_raw_create */
249 if ((netid == NULL) && (flag == 1))
250 {
251 return (FALSE);
252 }
253
254 rwlock_wrlock (&svc_lock);
255 if ((s = svc_find (prog, vers, &prev, netid)) != NULL)
256 {
257 if (netid)
258 free (netid);
259 if (s->sc_dispatch == dispatch)
260 goto rpcb_it; /* he is registering another xptr */
261 rwlock_unlock (&svc_lock);
262 return (FALSE);
263 }
264 s = mem_alloc (sizeof (struct svc_callout));
265 if (s == NULL)
266 {
267 if (netid)
268 free (netid);
269 rwlock_unlock (&svc_lock);
270 return (FALSE);
271 }
272
273 s->sc_prog = prog;
274 s->sc_vers = vers;
275 s->sc_dispatch = dispatch;
276 s->sc_netid = netid;
277 s->sc_next = svc_head;
278 svc_head = s;
279
280 if ((xprt->xp_netid == NULL) && (flag == 1) && netid)
281 ((SVCXPRT *) xprt)->xp_netid = strdup (netid);
282
283 rpcb_it:
284 rwlock_unlock (&svc_lock);
285 /* now register the information with the local binder service */
286 if (nconf)
287 {
288 /*LINTED const castaway */
289 dummy = rpcb_set (prog, vers, (struct netconfig *) nconf,
290 &((SVCXPRT *) xprt)->xp_ltaddr);
291 return (dummy);
292 }
293 return (TRUE);
294 }
295
296 /*
297 * Remove a service program from the callout list.
298 */
299 void
300 svc_unreg (prog, vers)
301 const rpcprog_t prog;
302 const rpcvers_t vers;
303 {
304 struct svc_callout *prev;
305 struct svc_callout *s;
306
307 /* unregister the information anyway */
308 (void) rpcb_unset (prog, vers, NULL);
309 rwlock_wrlock (&svc_lock);
310 while ((s = svc_find (prog, vers, &prev, NULL)) != NULL)
311 {
312 if (prev == NULL)
313 {
314 svc_head = s->sc_next;
315 }
316 else
317 {
318 prev->sc_next = s->sc_next;
319 }
320 s->sc_next = NULL;
321 if (s->sc_netid)
322 mem_free (s->sc_netid, sizeof (s->sc_netid) + 1);
323 mem_free (s, sizeof (struct svc_callout));
324 }
325 rwlock_unlock (&svc_lock);
326 }
327
328 /* ********************** CALLOUT list related stuff ************* */
329
330 #ifdef PORTMAP
331 /*
332 * Add a service program to the callout list.
333 * The dispatch routine will be called when a rpc request for this
334 * program number comes in.
335 */
336 bool_t
337 svc_register (xprt, prog, vers, dispatch, protocol)
338 SVCXPRT *xprt;
339 u_long prog;
340 u_long vers;
341 void (*dispatch) (struct svc_req *, SVCXPRT *);
342 int protocol;
343 {
344 struct svc_callout *prev;
345 struct svc_callout *s;
346
347 assert (xprt != NULL);
348 assert (dispatch != NULL);
349
350 if ((s = svc_find ((rpcprog_t) prog, (rpcvers_t) vers, &prev, NULL)) !=
351 NULL)
352 {
353 if (s->sc_dispatch == dispatch)
354 goto pmap_it; /* he is registering another xptr */
355 return (FALSE);
356 }
357 s = mem_alloc (sizeof (struct svc_callout));
358 if (s == NULL)
359 {
360 return (FALSE);
361 }
362 s->sc_prog = (rpcprog_t) prog;
363 s->sc_vers = (rpcvers_t) vers;
364 s->sc_dispatch = dispatch;
365 s->sc_next = svc_head;
366 svc_head = s;
367 pmap_it:
368 /* now register the information with the local binder service */
369 if (protocol)
370 {
371 return (pmap_set (prog, vers, protocol, xprt->xp_port));
372 }
373 return (TRUE);
374 }
375
376 /*
377 * Remove a service program from the callout list.
378 */
379 void
380 svc_unregister (prog, vers)
381 u_long prog;
382 u_long vers;
383 {
384 struct svc_callout *prev;
385 struct svc_callout *s;
386
387 if ((s = svc_find ((rpcprog_t) prog, (rpcvers_t) vers, &prev, NULL)) ==
388 NULL)
389 return;
390 if (prev == NULL)
391 {
392 svc_head = s->sc_next;
393 }
394 else
395 {
396 prev->sc_next = s->sc_next;
397 }
398 s->sc_next = NULL;
399 mem_free (s, sizeof (struct svc_callout));
400 /* now unregister the information with the local binder service */
401 (void) pmap_unset (prog, vers);
402 }
403 #endif /* PORTMAP */
404
405 /*
406 * Search the callout list for a program number, return the callout
407 * struct.
408 */
409 static struct svc_callout *
410 svc_find (prog, vers, prev, netid)
411 rpcprog_t prog;
412 rpcvers_t vers;
413 struct svc_callout **prev;
414 char *netid;
415 {
416 struct svc_callout *s, *p;
417
418 assert (prev != NULL);
419
420 p = NULL;
421 for (s = svc_head; s != NULL; s = s->sc_next)
422 {
423 if (((s->sc_prog == prog) && (s->sc_vers == vers)) &&
424 ((netid == NULL) || (s->sc_netid == NULL) ||
425 (strcmp (netid, s->sc_netid) == 0)))
426 break;
427 p = s;
428 }
429 *prev = p;
430 return (s);
431 }
432
433 /* ******************* REPLY GENERATION ROUTINES ************ */
434
435 /*
436 * Send a reply to an rpc request
437 */
438 bool_t
439 svc_sendreply (xprt, xdr_results, xdr_location)
440 SVCXPRT *xprt;
441 xdrproc_t xdr_results;
442 void *xdr_location;
443 {
444 struct rpc_msg rply;
445
446 assert (xprt != NULL);
447
448 rply.rm_direction = REPLY;
449 rply.rm_reply.rp_stat = MSG_ACCEPTED;
450 rply.acpted_rply.ar_verf = xprt->xp_verf;
451 rply.acpted_rply.ar_stat = SUCCESS;
452 rply.acpted_rply.ar_results.where = xdr_location;
453 rply.acpted_rply.ar_results.proc = xdr_results;
454 return (SVC_REPLY (xprt, &rply));
455 }
456
457 /*
458 * No procedure error reply
459 */
460 void
461 svcerr_noproc (xprt)
462 SVCXPRT *xprt;
463 {
464 struct rpc_msg rply;
465
466 assert (xprt != NULL);
467
468 rply.rm_direction = REPLY;
469 rply.rm_reply.rp_stat = MSG_ACCEPTED;
470 rply.acpted_rply.ar_verf = xprt->xp_verf;
471 rply.acpted_rply.ar_stat = PROC_UNAVAIL;
472 SVC_REPLY (xprt, &rply);
473 }
474
475 /*
476 * Can't decode args error reply
477 */
478 void
479 svcerr_decode (xprt)
480 SVCXPRT *xprt;
481 {
482 struct rpc_msg rply;
483
484 assert (xprt != NULL);
485
486 rply.rm_direction = REPLY;
487 rply.rm_reply.rp_stat = MSG_ACCEPTED;
488 rply.acpted_rply.ar_verf = xprt->xp_verf;
489 rply.acpted_rply.ar_stat = GARBAGE_ARGS;
490 SVC_REPLY (xprt, &rply);
491 }
492
493 /*
494 * Some system error
495 */
496 void
497 svcerr_systemerr (xprt)
498 SVCXPRT *xprt;
499 {
500 struct rpc_msg rply;
501
502 assert (xprt != NULL);
503
504 rply.rm_direction = REPLY;
505 rply.rm_reply.rp_stat = MSG_ACCEPTED;
506 rply.acpted_rply.ar_verf = xprt->xp_verf;
507 rply.acpted_rply.ar_stat = SYSTEM_ERR;
508 SVC_REPLY (xprt, &rply);
509 }
510
511 #if 0
512 /*
513 * Tell RPC package to not complain about version errors to the client. This
514 * is useful when revving broadcast protocols that sit on a fixed address.
515 * There is really one (or should be only one) example of this kind of
516 * protocol: the portmapper (or rpc binder).
517 */
518 void
519 __svc_versquiet_on (xprt)
520 SVCXPRT *xprt;
521 {
522 svc_flags (xprt) |= SVC_VERSQUIET;
523 }
524
525 void
526 __svc_versquiet_off (xprt)
527 SVCXPRT *xprt;
528 {
529 svc_flags (xprt) &= ~SVC_VERSQUIET;
530 }
531
532 void
533 svc_versquiet (xprt)
534 SVCXPRT *xprt;
535 {
536 __svc_versquiet_on (xprt);
537 }
538
539 int
540 __svc_versquiet_get (xprt)
541 SVCXPRT *xprt;
542 {
543 return version_keepquiet (xprt);
544 }
545 #endif
546
547 /*
548 * Authentication error reply
549 */
550 void
551 svcerr_auth (xprt, why)
552 SVCXPRT *xprt;
553 enum auth_stat why;
554 {
555 struct rpc_msg rply;
556
557 assert (xprt != NULL);
558
559 rply.rm_direction = REPLY;
560 rply.rm_reply.rp_stat = MSG_DENIED;
561 rply.rjcted_rply.rj_stat = AUTH_ERROR;
562 rply.rjcted_rply.rj_why = why;
563 SVC_REPLY (xprt, &rply);
564 }
565
566 /*
567 * Auth too weak error reply
568 */
569 void
570 svcerr_weakauth (xprt)
571 SVCXPRT *xprt;
572 {
573
574 assert (xprt != NULL);
575
576 svcerr_auth (xprt, AUTH_TOOWEAK);
577 }
578
579 /*
580 * Program unavailable error reply
581 */
582 void
583 svcerr_noprog (xprt)
584 SVCXPRT *xprt;
585 {
586 struct rpc_msg rply;
587
588 assert (xprt != NULL);
589
590 rply.rm_direction = REPLY;
591 rply.rm_reply.rp_stat = MSG_ACCEPTED;
592 rply.acpted_rply.ar_verf = xprt->xp_verf;
593 rply.acpted_rply.ar_stat = PROG_UNAVAIL;
594 SVC_REPLY (xprt, &rply);
595 }
596
597 /*
598 * Program version mismatch error reply
599 */
600 void
601 svcerr_progvers (xprt, low_vers, high_vers)
602 SVCXPRT *xprt;
603 rpcvers_t low_vers;
604 rpcvers_t high_vers;
605 {
606 struct rpc_msg rply;
607
608 assert (xprt != NULL);
609
610 rply.rm_direction = REPLY;
611 rply.rm_reply.rp_stat = MSG_ACCEPTED;
612 rply.acpted_rply.ar_verf = xprt->xp_verf;
613 rply.acpted_rply.ar_stat = PROG_MISMATCH;
614 rply.acpted_rply.ar_vers.low = (u_int32_t) low_vers;
615 rply.acpted_rply.ar_vers.high = (u_int32_t) high_vers;
616 SVC_REPLY (xprt, &rply);
617 }
618
619 /* ******************* SERVER INPUT STUFF ******************* */
620
621 /*
622 * Get server side input from some transport.
623 *
624 * Statement of authentication parameters management:
625 * This function owns and manages all authentication parameters, specifically
626 * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and
627 * the "cooked" credentials (rqst->rq_clntcred).
628 * However, this function does not know the structure of the cooked
629 * credentials, so it make the following assumptions:
630 * a) the structure is contiguous (no pointers), and
631 * b) the cred structure size does not exceed RQCRED_SIZE bytes.
632 * In all events, all three parameters are freed upon exit from this routine.
633 * The storage is trivially management on the call stack in user land, but
634 * is mallocated in kernel land.
635 */
636
637 void
638 svc_getreq (rdfds)
639 int rdfds;
640 {
641 fd_set readfds;
642
643 FD_ZERO (&readfds);
644 readfds.fds_bits[0] = rdfds;
645 svc_getreqset (&readfds);
646 }
647
648 void
649 svc_getreqset (readfds)
650 fd_set *readfds;
651 {
652 int bit, fd;
653 fd_mask mask, *maskp;
654 int sock;
655 int setsize;
656
657 assert (readfds != NULL);
658
659 setsize = _rpc_dtablesize ();
660 maskp = readfds->fds_bits;
661 for (sock = 0; sock < setsize; sock += NFDBITS)
662 {
663 for (mask = *maskp++; (bit = ffsl(mask)) != 0; mask ^= (1L << (bit - 1)))
664 {
665 /* sock has input waiting */
666 fd = sock + bit - 1;
667 svc_getreq_common (fd);
668 }
669 }
670 }
671
672 void
673 svc_getreq_common (fd)
674 int fd;
675 {
676 SVCXPRT *xprt;
677 struct svc_req r;
678 struct rpc_msg msg;
679 int prog_found;
680 rpcvers_t low_vers;
681 rpcvers_t high_vers;
682 enum xprt_stat stat;
683 char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE];
684
685 msg.rm_call.cb_cred.oa_base = cred_area;
686 msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
687 r.rq_clntcred = &(cred_area[2 * MAX_AUTH_BYTES]);
688
689 rwlock_rdlock (&svc_fd_lock);
690 xprt = __svc_xports[fd];
691 rwlock_unlock (&svc_fd_lock);
692 if (xprt == NULL)
693 /* But do we control sock? */
694 return;
695 /* now receive msgs from xprtprt (support batch calls) */
696 do
697 {
698 if (SVC_RECV (xprt, &msg))
699 {
700 bool_t no_dispatch;
701
702 /* now find the exported program and call it */
703 struct svc_callout *s;
704 enum auth_stat why;
705
706 r.rq_xprt = xprt;
707 r.rq_prog = msg.rm_call.cb_prog;
708 r.rq_vers = msg.rm_call.cb_vers;
709 r.rq_proc = msg.rm_call.cb_proc;
710 r.rq_cred = msg.rm_call.cb_cred;
711 /* first authenticate the message */
712 why = _gss_authenticate(&r, &msg, &no_dispatch);
713 if (why != AUTH_OK)
714 {
715 svcerr_auth (xprt, why);
716 goto call_done;
717 }
718 if (no_dispatch)
719 goto call_done;
720 /* now match message with a registered service */
721 prog_found = FALSE;
722 low_vers = (rpcvers_t) - 1L;
723 high_vers = (rpcvers_t) 0L;
724 for (s = svc_head; s != NULL; s = s->sc_next)
725 {
726 if (s->sc_prog == r.rq_prog)
727 {
728 if (s->sc_vers == r.rq_vers)
729 {
730 (*s->sc_dispatch) (&r, xprt);
731 goto call_done;
732 } /* found correct version */
733 prog_found = TRUE;
734 if (s->sc_vers < low_vers)
735 low_vers = s->sc_vers;
736 if (s->sc_vers > high_vers)
737 high_vers = s->sc_vers;
738 } /* found correct program */
739 }
740 /*
741 * if we got here, the program or version
742 * is not served ...
743 */
744 if (prog_found)
745 svcerr_progvers (xprt, low_vers, high_vers);
746 else
747 svcerr_noprog (xprt);
748 /* Fall through to ... */
749 }
750 /*
751 * Check if the xprt has been disconnected in a
752 * recursive call in the service dispatch routine.
753 * If so, then break.
754 */
755 rwlock_rdlock (&svc_fd_lock);
756
757 if (xprt != __svc_xports[fd])
758 {
759 rwlock_unlock (&svc_fd_lock);
760 break;
761 }
762 rwlock_unlock (&svc_fd_lock);
763 call_done:
764 if ((stat = SVC_STAT (xprt)) == XPRT_DIED)
765 {
766 SVC_DESTROY (xprt);
767 break;
768 }
769 }
770 while (stat == XPRT_MOREREQS);
771 }
772
773
774 void
775 svc_getreq_poll (pfdp, pollretval)
776 struct pollfd *pfdp;
777 int pollretval;
778 {
779 int fds_found, i;
780
781 for (i = fds_found = 0; i < svc_max_pollfd; ++i)
782 {
783 struct pollfd *p = &pfdp[i];
784
785 if (p->fd != -1 && p->revents)
786 {
787 /* fd has input waiting */
788 if (p->revents & POLLNVAL)
789 xprt_unregister (__svc_xports[p->fd]);
790 else
791 svc_getreq_common (p->fd);
792
793 if (++fds_found >= pollretval)
794 break;
795 }
796 }
797 }
798
799 bool_t
800 rpc_control (int what, void *arg)
801 {
802 int val;
803
804 switch (what)
805 {
806 case RPC_SVC_CONNMAXREC_SET:
807 val = *(int *) arg;
808 if (val <= 0)
809 return FALSE;
810 __svc_maxrec = val;
811 return TRUE;
812 case RPC_SVC_CONNMAXREC_GET:
813 *(int *) arg = __svc_maxrec;
814 return TRUE;
815 default:
816 break;
817 }
818 return FALSE;
819 }