svc.c revision 1.22 1 /* $NetBSD: svc.c,v 1.22 2001/01/04 14:42:21 lukem Exp $ */
2
3 /*
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
10 *
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 *
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
18 *
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
22 *
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
26 *
27 * Sun Microsystems, Inc.
28 * 2550 Garcia Avenue
29 * Mountain View, California 94043
30 */
31
32 #include <sys/cdefs.h>
33 #if defined(LIBC_SCCS) && !defined(lint)
34 #if 0
35 static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
36 static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
37 #else
38 __RCSID("$NetBSD: svc.c,v 1.22 2001/01/04 14:42:21 lukem Exp $");
39 #endif
40 #endif
41
42 /*
43 * svc.c, Server-side remote procedure call interface.
44 *
45 * There are two sets of procedures here. The xprt routines are
46 * for handling transport handles. The svc routines handle the
47 * list of service routines.
48 *
49 * Copyright (C) 1984, Sun Microsystems, Inc.
50 */
51
52 #include "namespace.h"
53 #include "reentrant.h"
54 #include <sys/types.h>
55 #include <sys/poll.h>
56 #include <assert.h>
57 #include <errno.h>
58 #include <stdlib.h>
59 #include <string.h>
60
61 #include <rpc/rpc.h>
62 #ifdef PORTMAP
63 #include <rpc/pmap_clnt.h>
64 #endif
65
66 #include "rpc_com.h"
67
68 #ifdef __weak_alias
69 __weak_alias(svc_getreq,_svc_getreq)
70 __weak_alias(svc_getreqset,_svc_getreqset)
71 __weak_alias(svc_getreq_common,_svc_getreq_common)
72 __weak_alias(svc_register,_svc_register)
73 __weak_alias(svc_reg,_svc_reg)
74 __weak_alias(svc_unreg,_svc_unreg)
75 __weak_alias(svc_sendreply,_svc_sendreply)
76 __weak_alias(svc_unregister,_svc_unregister)
77 __weak_alias(svcerr_auth,_svcerr_auth)
78 __weak_alias(svcerr_decode,_svcerr_decode)
79 __weak_alias(svcerr_noproc,_svcerr_noproc)
80 __weak_alias(svcerr_noprog,_svcerr_noprog)
81 __weak_alias(svcerr_progvers,_svcerr_progvers)
82 __weak_alias(svcerr_systemerr,_svcerr_systemerr)
83 __weak_alias(svcerr_weakauth,_svcerr_weakauth)
84 __weak_alias(xprt_register,_xprt_register)
85 __weak_alias(xprt_unregister,_xprt_unregister)
86 #endif
87
88 static SVCXPRT **xports;
89
90 #define RQCRED_SIZE 400 /* this size is excessive */
91
92 #define SVC_VERSQUIET 0x0001 /* keep quiet about vers mismatch */
93 #define version_keepquiet(xp) ((u_long)(xp)->xp_p3 & SVC_VERSQUIET)
94
95 #define max(a, b) (a > b ? a : b)
96
97 /*
98 * The services list
99 * Each entry represents a set of procedures (an rpc program).
100 * The dispatch routine takes request structs and runs the
101 * apropriate procedure.
102 */
103 static struct svc_callout {
104 struct svc_callout *sc_next;
105 rpcprog_t sc_prog;
106 rpcvers_t sc_vers;
107 char *sc_netid;
108 void (*sc_dispatch) __P((struct svc_req *, SVCXPRT *));
109 } *svc_head;
110
111 #ifdef __REENT
112 extern rwlock_t svc_lock;
113 extern rwlock_t svc_fd_lock;
114 #endif
115
116 static struct svc_callout *svc_find __P((rpcprog_t, rpcvers_t,
117 struct svc_callout **, char *));
118
119 /* *************** SVCXPRT related stuff **************** */
120
121 /*
122 * Activate a transport handle.
123 */
124 void
125 xprt_register(xprt)
126 SVCXPRT *xprt;
127 {
128 int sock;
129
130 _DIAGASSERT(xprt != NULL);
131
132 sock = xprt->xp_fd;
133
134 rwlock_wrlock(&svc_fd_lock);
135 if (xports == NULL) {
136 xports = (SVCXPRT **)
137 mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *));
138 if (xports == NULL)
139 return;
140 memset(xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *));
141 }
142 if (sock < FD_SETSIZE) {
143 xports[sock] = xprt;
144 FD_SET(sock, &svc_fdset);
145 svc_maxfd = max(svc_maxfd, sock);
146 }
147 rwlock_unlock(&svc_fd_lock);
148 }
149
150 /*
151 * De-activate a transport handle.
152 */
153 void
154 xprt_unregister(xprt)
155 SVCXPRT *xprt;
156 {
157 int sock;
158
159 _DIAGASSERT(xprt != NULL);
160
161 sock = xprt->xp_fd;
162
163 rwlock_wrlock(&svc_fd_lock);
164 if ((sock < FD_SETSIZE) && (xports[sock] == xprt)) {
165 xports[sock] = NULL;
166 FD_CLR(sock, &svc_fdset);
167 if (sock >= svc_maxfd) {
168 for (svc_maxfd--; svc_maxfd>=0; svc_maxfd--)
169 if (xports[svc_maxfd])
170 break;
171 }
172 }
173 rwlock_unlock(&svc_fd_lock);
174 }
175
176 /*
177 * Add a service program to the callout list.
178 * The dispatch routine will be called when a rpc request for this
179 * program number comes in.
180 */
181 bool_t
182 svc_reg(xprt, prog, vers, dispatch, nconf)
183 SVCXPRT *xprt;
184 const rpcprog_t prog;
185 const rpcvers_t vers;
186 void (*dispatch) __P((struct svc_req *, SVCXPRT *));
187 const struct netconfig *nconf;
188 {
189 bool_t dummy;
190 struct svc_callout *prev;
191 struct svc_callout *s;
192 struct netconfig *tnconf;
193 char *netid = NULL;
194 int flag = 0;
195
196 _DIAGASSERT(xprt != NULL);
197 /* XXX: dispatch may be NULL ??? */
198
199 /* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */
200
201 if (xprt->xp_netid) {
202 netid = strdup(xprt->xp_netid);
203 flag = 1;
204 } else if (nconf && nconf->nc_netid) {
205 netid = strdup(nconf->nc_netid);
206 flag = 1;
207 } else if ((tnconf = __rpcgettp(xprt->xp_fd)) != NULL) {
208 netid = strdup(tnconf->nc_netid);
209 flag = 1;
210 freenetconfigent(tnconf);
211 } /* must have been created with svc_raw_create */
212 if ((netid == NULL) && (flag == 1)) {
213 return (FALSE);
214 }
215
216 rwlock_wrlock(&svc_lock);
217 if ((s = svc_find(prog, vers, &prev, netid)) != NULL) {
218 if (netid)
219 free(netid);
220 if (s->sc_dispatch == dispatch)
221 goto rpcb_it; /* he is registering another xptr */
222 rwlock_unlock(&svc_lock);
223 return (FALSE);
224 }
225 s = mem_alloc(sizeof (struct svc_callout));
226 if (s == NULL) {
227 if (netid)
228 free(netid);
229 rwlock_unlock(&svc_lock);
230 return (FALSE);
231 }
232
233 s->sc_prog = prog;
234 s->sc_vers = vers;
235 s->sc_dispatch = dispatch;
236 s->sc_netid = netid;
237 s->sc_next = svc_head;
238 svc_head = s;
239
240 if ((xprt->xp_netid == NULL) && (flag == 1) && netid)
241 ((SVCXPRT *) xprt)->xp_netid = strdup(netid);
242
243 rpcb_it:
244 rwlock_unlock(&svc_lock);
245 /* now register the information with the local binder service */
246 if (nconf) {
247 /*LINTED const castaway*/
248 dummy = rpcb_set(prog, vers, (struct netconfig *) nconf,
249 &((SVCXPRT *) xprt)->xp_ltaddr);
250 return (dummy);
251 }
252 return (TRUE);
253 }
254
255 /*
256 * Remove a service program from the callout list.
257 */
258 void
259 svc_unreg(prog, vers)
260 const rpcprog_t prog;
261 const rpcvers_t vers;
262 {
263 struct svc_callout *prev;
264 struct svc_callout *s;
265
266 /* unregister the information anyway */
267 (void) rpcb_unset(prog, vers, NULL);
268 rwlock_wrlock(&svc_lock);
269 while ((s = svc_find(prog, vers, &prev, NULL)) != NULL) {
270 if (prev == NULL) {
271 svc_head = s->sc_next;
272 } else {
273 prev->sc_next = s->sc_next;
274 }
275 s->sc_next = NULL;
276 if (s->sc_netid)
277 mem_free(s->sc_netid, sizeof (s->sc_netid) + 1);
278 mem_free(s, sizeof (struct svc_callout));
279 }
280 rwlock_unlock(&svc_lock);
281 }
282
283 /* ********************** CALLOUT list related stuff ************* */
284
285 #ifdef PORTMAP
286 /*
287 * Add a service program to the callout list.
288 * The dispatch routine will be called when a rpc request for this
289 * program number comes in.
290 */
291 bool_t
292 svc_register(xprt, prog, vers, dispatch, protocol)
293 SVCXPRT *xprt;
294 u_long prog;
295 u_long vers;
296 void (*dispatch) __P((struct svc_req *, SVCXPRT *));
297 int protocol;
298 {
299 struct svc_callout *prev;
300 struct svc_callout *s;
301
302 _DIAGASSERT(xprt != NULL);
303 _DIAGASSERT(dispatch != NULL);
304
305 if ((s = svc_find((rpcprog_t)prog, (rpcvers_t)vers, &prev, NULL)) !=
306 NULL) {
307 if (s->sc_dispatch == dispatch)
308 goto pmap_it; /* he is registering another xptr */
309 return (FALSE);
310 }
311 s = mem_alloc(sizeof(struct svc_callout));
312 if (s == NULL) {
313 return (FALSE);
314 }
315 s->sc_prog = (rpcprog_t)prog;
316 s->sc_vers = (rpcvers_t)vers;
317 s->sc_dispatch = dispatch;
318 s->sc_next = svc_head;
319 svc_head = s;
320 pmap_it:
321 /* now register the information with the local binder service */
322 if (protocol) {
323 return (pmap_set(prog, vers, protocol, xprt->xp_port));
324 }
325 return (TRUE);
326 }
327
328 /*
329 * Remove a service program from the callout list.
330 */
331 void
332 svc_unregister(prog, vers)
333 u_long prog;
334 u_long vers;
335 {
336 struct svc_callout *prev;
337 struct svc_callout *s;
338
339 if ((s = svc_find((rpcprog_t)prog, (rpcvers_t)vers, &prev, NULL)) ==
340 NULL)
341 return;
342 if (prev == NULL) {
343 svc_head = s->sc_next;
344 } else {
345 prev->sc_next = s->sc_next;
346 }
347 s->sc_next = NULL;
348 mem_free(s, sizeof(struct svc_callout));
349 /* now unregister the information with the local binder service */
350 (void)pmap_unset(prog, vers);
351 }
352 #endif /* PORTMAP */
353
354 /*
355 * Search the callout list for a program number, return the callout
356 * struct.
357 */
358 static struct svc_callout *
359 svc_find(prog, vers, prev, netid)
360 rpcprog_t prog;
361 rpcvers_t vers;
362 struct svc_callout **prev;
363 char *netid;
364 {
365 struct svc_callout *s, *p;
366
367 _DIAGASSERT(prev != NULL);
368 /* netid is handled below */
369
370 p = NULL;
371 for (s = svc_head; s != NULL; s = s->sc_next) {
372 if (((s->sc_prog == prog) && (s->sc_vers == vers)) &&
373 ((netid == NULL) || (s->sc_netid == NULL) ||
374 (strcmp(netid, s->sc_netid) == 0)))
375 break;
376 p = s;
377 }
378 *prev = p;
379 return (s);
380 }
381
382 /* ******************* REPLY GENERATION ROUTINES ************ */
383
384 /*
385 * Send a reply to an rpc request
386 */
387 bool_t
388 svc_sendreply(xprt, xdr_results, xdr_location)
389 SVCXPRT *xprt;
390 xdrproc_t xdr_results;
391 caddr_t xdr_location;
392 {
393 struct rpc_msg rply;
394
395 _DIAGASSERT(xprt != NULL);
396
397 rply.rm_direction = REPLY;
398 rply.rm_reply.rp_stat = MSG_ACCEPTED;
399 rply.acpted_rply.ar_verf = xprt->xp_verf;
400 rply.acpted_rply.ar_stat = SUCCESS;
401 rply.acpted_rply.ar_results.where = xdr_location;
402 rply.acpted_rply.ar_results.proc = xdr_results;
403 return (SVC_REPLY(xprt, &rply));
404 }
405
406 /*
407 * No procedure error reply
408 */
409 void
410 svcerr_noproc(xprt)
411 SVCXPRT *xprt;
412 {
413 struct rpc_msg rply;
414
415 _DIAGASSERT(xprt != NULL);
416
417 rply.rm_direction = REPLY;
418 rply.rm_reply.rp_stat = MSG_ACCEPTED;
419 rply.acpted_rply.ar_verf = xprt->xp_verf;
420 rply.acpted_rply.ar_stat = PROC_UNAVAIL;
421 SVC_REPLY(xprt, &rply);
422 }
423
424 /*
425 * Can't decode args error reply
426 */
427 void
428 svcerr_decode(xprt)
429 SVCXPRT *xprt;
430 {
431 struct rpc_msg rply;
432
433 _DIAGASSERT(xprt != NULL);
434
435 rply.rm_direction = REPLY;
436 rply.rm_reply.rp_stat = MSG_ACCEPTED;
437 rply.acpted_rply.ar_verf = xprt->xp_verf;
438 rply.acpted_rply.ar_stat = GARBAGE_ARGS;
439 SVC_REPLY(xprt, &rply);
440 }
441
442 /*
443 * Some system error
444 */
445 void
446 svcerr_systemerr(xprt)
447 SVCXPRT *xprt;
448 {
449 struct rpc_msg rply;
450
451 _DIAGASSERT(xprt != NULL);
452
453 rply.rm_direction = REPLY;
454 rply.rm_reply.rp_stat = MSG_ACCEPTED;
455 rply.acpted_rply.ar_verf = xprt->xp_verf;
456 rply.acpted_rply.ar_stat = SYSTEM_ERR;
457 SVC_REPLY(xprt, &rply);
458 }
459
460 #if 0
461 /*
462 * Tell RPC package to not complain about version errors to the client. This
463 * is useful when revving broadcast protocols that sit on a fixed address.
464 * There is really one (or should be only one) example of this kind of
465 * protocol: the portmapper (or rpc binder).
466 */
467 void
468 __svc_versquiet_on(xprt)
469 SVCXPRT *xprt;
470 {
471 u_long tmp;
472
473 _DIAGASSERT(xprt != NULL);
474
475 tmp = ((u_long) xprt->xp_p3) | SVC_VERSQUIET;
476 xprt->xp_p3 = (caddr_t) tmp;
477 }
478
479 void
480 __svc_versquiet_off(xprt)
481 SVCXPRT *xprt;
482 {
483 u_long tmp;
484
485 _DIAGASSERT(xprt != NULL);
486
487 tmp = ((u_long) xprt->xp_p3) & ~SVC_VERSQUIET;
488 xprt->xp_p3 = (caddr_t) tmp;
489 }
490
491 void
492 svc_versquiet(xprt)
493 SVCXPRT *xprt;
494 {
495 __svc_versquiet_on(xprt);
496 }
497
498 int
499 __svc_versquiet_get(xprt)
500 SVCXPRT *xprt;
501 {
502
503 _DIAGASSERT(xprt != NULL);
504
505 return ((int) xprt->xp_p3) & SVC_VERSQUIET;
506 }
507 #endif
508
509 /*
510 * Authentication error reply
511 */
512 void
513 svcerr_auth(xprt, why)
514 SVCXPRT *xprt;
515 enum auth_stat why;
516 {
517 struct rpc_msg rply;
518
519 _DIAGASSERT(xprt != NULL);
520
521 rply.rm_direction = REPLY;
522 rply.rm_reply.rp_stat = MSG_DENIED;
523 rply.rjcted_rply.rj_stat = AUTH_ERROR;
524 rply.rjcted_rply.rj_why = why;
525 SVC_REPLY(xprt, &rply);
526 }
527
528 /*
529 * Auth too weak error reply
530 */
531 void
532 svcerr_weakauth(xprt)
533 SVCXPRT *xprt;
534 {
535
536 _DIAGASSERT(xprt != NULL);
537
538 svcerr_auth(xprt, AUTH_TOOWEAK);
539 }
540
541 /*
542 * Program unavailable error reply
543 */
544 void
545 svcerr_noprog(xprt)
546 SVCXPRT *xprt;
547 {
548 struct rpc_msg rply;
549
550 _DIAGASSERT(xprt != NULL);
551
552 rply.rm_direction = REPLY;
553 rply.rm_reply.rp_stat = MSG_ACCEPTED;
554 rply.acpted_rply.ar_verf = xprt->xp_verf;
555 rply.acpted_rply.ar_stat = PROG_UNAVAIL;
556 SVC_REPLY(xprt, &rply);
557 }
558
559 /*
560 * Program version mismatch error reply
561 */
562 void
563 svcerr_progvers(xprt, low_vers, high_vers)
564 SVCXPRT *xprt;
565 rpcvers_t low_vers;
566 rpcvers_t high_vers;
567 {
568 struct rpc_msg rply;
569
570 _DIAGASSERT(xprt != NULL);
571
572 rply.rm_direction = REPLY;
573 rply.rm_reply.rp_stat = MSG_ACCEPTED;
574 rply.acpted_rply.ar_verf = xprt->xp_verf;
575 rply.acpted_rply.ar_stat = PROG_MISMATCH;
576 rply.acpted_rply.ar_vers.low = (u_int32_t)low_vers;
577 rply.acpted_rply.ar_vers.high = (u_int32_t)high_vers;
578 SVC_REPLY(xprt, &rply);
579 }
580
581 /* ******************* SERVER INPUT STUFF ******************* */
582
583 /*
584 * Get server side input from some transport.
585 *
586 * Statement of authentication parameters management:
587 * This function owns and manages all authentication parameters, specifically
588 * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and
589 * the "cooked" credentials (rqst->rq_clntcred).
590 * However, this function does not know the structure of the cooked
591 * credentials, so it make the following assumptions:
592 * a) the structure is contiguous (no pointers), and
593 * b) the cred structure size does not exceed RQCRED_SIZE bytes.
594 * In all events, all three parameters are freed upon exit from this routine.
595 * The storage is trivially management on the call stack in user land, but
596 * is mallocated in kernel land.
597 */
598
599 void
600 svc_getreq(rdfds)
601 int rdfds;
602 {
603 fd_set readfds;
604
605 FD_ZERO(&readfds);
606 readfds.fds_bits[0] = rdfds;
607 svc_getreqset(&readfds);
608 }
609
610 void
611 svc_getreqset(readfds)
612 fd_set *readfds;
613 {
614 int bit, fd;
615 int32_t mask, *maskp;
616 int sock;
617
618 _DIAGASSERT(readfds != NULL);
619
620 maskp = readfds->fds_bits;
621 for (sock = 0; sock < FD_SETSIZE; sock += NFDBITS) {
622 for (mask = *maskp++; (bit = ffs(mask)) != 0;
623 mask ^= (1 << (bit - 1))) {
624 /* sock has input waiting */
625 fd = sock + bit - 1;
626 svc_getreq_common(fd);
627 }
628 }
629 }
630
631 void
632 svc_getreq_common(fd)
633 int fd;
634 {
635 SVCXPRT *xprt;
636 struct svc_req r;
637 struct rpc_msg msg;
638 int prog_found;
639 rpcvers_t low_vers;
640 rpcvers_t high_vers;
641 enum xprt_stat stat;
642 char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];
643
644 msg.rm_call.cb_cred.oa_base = cred_area;
645 msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
646 r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
647
648 rwlock_rdlock(&svc_fd_lock);
649 xprt = xports[fd];
650 rwlock_unlock(&svc_fd_lock);
651 if (xprt == NULL)
652 /* But do we control sock? */
653 return;
654 /* now receive msgs from xprtprt (support batch calls) */
655 do {
656 if (SVC_RECV(xprt, &msg)) {
657
658 /* now find the exported program and call it */
659 struct svc_callout *s;
660 enum auth_stat why;
661
662 r.rq_xprt = xprt;
663 r.rq_prog = msg.rm_call.cb_prog;
664 r.rq_vers = msg.rm_call.cb_vers;
665 r.rq_proc = msg.rm_call.cb_proc;
666 r.rq_cred = msg.rm_call.cb_cred;
667 /* first authenticate the message */
668 if ((why = _authenticate(&r, &msg)) != AUTH_OK) {
669 svcerr_auth(xprt, why);
670 goto call_done;
671 }
672 /* now match message with a registered service*/
673 prog_found = FALSE;
674 low_vers = (rpcvers_t) -1L;
675 high_vers = (rpcvers_t) 0L;
676 for (s = svc_head; s != NULL; s = s->sc_next) {
677 if (s->sc_prog == r.rq_prog) {
678 if (s->sc_vers == r.rq_vers) {
679 (*s->sc_dispatch)(&r, xprt);
680 goto call_done;
681 } /* found correct version */
682 prog_found = TRUE;
683 if (s->sc_vers < low_vers)
684 low_vers = s->sc_vers;
685 if (s->sc_vers > high_vers)
686 high_vers = s->sc_vers;
687 } /* found correct program */
688 }
689 /*
690 * if we got here, the program or version
691 * is not served ...
692 */
693 if (prog_found)
694 svcerr_progvers(xprt, low_vers, high_vers);
695 else
696 svcerr_noprog(xprt);
697 /* Fall through to ... */
698 }
699 /*
700 * Check if the xprt has been disconnected in a
701 * recursive call in the service dispatch routine.
702 * If so, then break.
703 */
704 rwlock_rdlock(&svc_fd_lock);
705 if (xprt != xports[fd]) {
706 rwlock_unlock(&svc_fd_lock);
707 break;
708 }
709 rwlock_unlock(&svc_fd_lock);
710 call_done:
711 if ((stat = SVC_STAT(xprt)) == XPRT_DIED){
712 SVC_DESTROY(xprt);
713 break;
714 }
715 } while (stat == XPRT_MOREREQS);
716 }
717
718
719 void
720 svc_getreq_poll(pfdp, pollretval)
721 struct pollfd *pfdp;
722 int pollretval;
723 {
724 int i;
725 int fds_found;
726
727 _DIAGASSERT(pfdp != NULL);
728
729 for (i = fds_found = 0; fds_found < pollretval; i++) {
730 struct pollfd *p = &pfdp[i];
731
732 if (p->revents) {
733 /* fd has input waiting */
734 fds_found++;
735 /*
736 * We assume that this function is only called
737 * via someone select()ing from svc_fdset or
738 * poll()ing from svc_pollset[]. Thus it's safe
739 * to handle the POLLNVAL event by simply turning
740 * the corresponding bit off in svc_fdset. The
741 * svc_pollset[] array is derived from svc_fdset
742 * and so will also be updated eventually.
743 *
744 * XXX Should we do an xprt_unregister() instead?
745 */
746 if (p->revents & POLLNVAL) {
747 rwlock_wrlock(&svc_fd_lock);
748 FD_CLR(p->fd, &svc_fdset);
749 rwlock_unlock(&svc_fd_lock);
750 } else
751 svc_getreq_common(p->fd);
752 }
753 }
754 }
755