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