svc.c (95658) | svc.c (109359) |
---|---|
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 --- 20 unchanged lines hidden (view full) --- 29 * Mountain View, California 94043 30 */ 31 32#if defined(LIBC_SCCS) && !defined(lint) 33static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro"; 34static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC"; 35#endif 36#include <sys/cdefs.h> | 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 --- 20 unchanged lines hidden (view full) --- 29 * Mountain View, California 94043 30 */ 31 32#if defined(LIBC_SCCS) && !defined(lint) 33static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro"; 34static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC"; 35#endif 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/lib/libc/rpc/svc.c 95658 2002-04-28 15:18:50Z des $"); | 37__FBSDID("$FreeBSD: head/lib/libc/rpc/svc.c 109359 2003-01-16 07:13:51Z mbr $"); |
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 * --- 12 unchanged lines hidden (view full) --- 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 | 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 * --- 12 unchanged lines hidden (view full) --- 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 |
66static SVCXPRT **xports; 67 | |
68#define RQCRED_SIZE 400 /* this size is excessive */ 69 70#define SVC_VERSQUIET 0x0001 /* keep quiet about vers mismatch */ 71#define version_keepquiet(xp) ((u_long)(xp)->xp_p3 & SVC_VERSQUIET) 72 73#define max(a, b) (a > b ? a : b) 74 75/* --- 10 unchanged lines hidden (view full) --- 86 void (*sc_dispatch)(struct svc_req *, SVCXPRT *); 87} *svc_head; 88 89extern rwlock_t svc_lock; 90extern rwlock_t svc_fd_lock; 91 92static struct svc_callout *svc_find(rpcprog_t, rpcvers_t, 93 struct svc_callout **, char *); | 66#define RQCRED_SIZE 400 /* this size is excessive */ 67 68#define SVC_VERSQUIET 0x0001 /* keep quiet about vers mismatch */ 69#define version_keepquiet(xp) ((u_long)(xp)->xp_p3 & SVC_VERSQUIET) 70 71#define max(a, b) (a > b ? a : b) 72 73/* --- 10 unchanged lines hidden (view full) --- 84 void (*sc_dispatch)(struct svc_req *, SVCXPRT *); 85} *svc_head; 86 87extern rwlock_t svc_lock; 88extern rwlock_t svc_fd_lock; 89 90static struct svc_callout *svc_find(rpcprog_t, rpcvers_t, 91 struct svc_callout **, char *); |
92static void __xprt_do_unregister (SVCXPRT *xprt, bool_t dolock); |
|
94 95/* *************** SVCXPRT related stuff **************** */ 96 97/* 98 * Activate a transport handle. 99 */ 100void 101xprt_register(xprt) 102 SVCXPRT *xprt; 103{ 104 int sock; 105 106 assert(xprt != NULL); 107 108 sock = xprt->xp_fd; 109 110 rwlock_wrlock(&svc_fd_lock); | 93 94/* *************** SVCXPRT related stuff **************** */ 95 96/* 97 * Activate a transport handle. 98 */ 99void 100xprt_register(xprt) 101 SVCXPRT *xprt; 102{ 103 int sock; 104 105 assert(xprt != NULL); 106 107 sock = xprt->xp_fd; 108 109 rwlock_wrlock(&svc_fd_lock); |
111 if (xports == NULL) { 112 xports = (SVCXPRT **) | 110 if (__svc_xports == NULL) { 111 __svc_xports = (SVCXPRT **) |
113 mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); | 112 mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); |
114 if (xports == NULL) | 113 if (__svc_xports == NULL) |
115 return; | 114 return; |
116 memset(xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *)); | 115 memset(__svc_xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *)); |
117 } 118 if (sock < FD_SETSIZE) { | 116 } 117 if (sock < FD_SETSIZE) { |
119 xports[sock] = xprt; | 118 __svc_xports[sock] = xprt; |
120 FD_SET(sock, &svc_fdset); 121 svc_maxfd = max(svc_maxfd, sock); 122 } 123 rwlock_unlock(&svc_fd_lock); 124} 125 | 119 FD_SET(sock, &svc_fdset); 120 svc_maxfd = max(svc_maxfd, sock); 121 } 122 rwlock_unlock(&svc_fd_lock); 123} 124 |
125void 126xprt_unregister(SVCXPRT *xprt) 127{ 128 __xprt_do_unregister(xprt, TRUE); 129} 130 131void 132__xprt_unregister_unlocked(SVCXPRT *xprt) 133{ 134 __xprt_do_unregister(xprt, FALSE); 135} 136 |
|
126/* 127 * De-activate a transport handle. 128 */ | 137/* 138 * De-activate a transport handle. 139 */ |
129void 130xprt_unregister(xprt) | 140static void 141__xprt_do_unregister(xprt, dolock) |
131 SVCXPRT *xprt; | 142 SVCXPRT *xprt; |
143 bool_t dolock; |
|
132{ 133 int sock; 134 135 assert(xprt != NULL); 136 137 sock = xprt->xp_fd; 138 | 144{ 145 int sock; 146 147 assert(xprt != NULL); 148 149 sock = xprt->xp_fd; 150 |
139 rwlock_wrlock(&svc_fd_lock); 140 if ((sock < FD_SETSIZE) && (xports[sock] == xprt)) { 141 xports[sock] = NULL; | 151 if (dolock) 152 rwlock_wrlock(&svc_fd_lock); 153 if ((sock < FD_SETSIZE) && (__svc_xports[sock] == xprt)) { 154 __svc_xports[sock] = NULL; |
142 FD_CLR(sock, &svc_fdset); 143 if (sock >= svc_maxfd) { 144 for (svc_maxfd--; svc_maxfd>=0; svc_maxfd--) | 155 FD_CLR(sock, &svc_fdset); 156 if (sock >= svc_maxfd) { 157 for (svc_maxfd--; svc_maxfd>=0; svc_maxfd--) |
145 if (xports[svc_maxfd]) | 158 if (__svc_xports[svc_maxfd]) |
146 break; 147 } 148 } | 159 break; 160 } 161 } |
149 rwlock_unlock(&svc_fd_lock); | 162 if (dolock) 163 rwlock_unlock(&svc_fd_lock); |
150} 151 152/* 153 * Add a service program to the callout list. 154 * The dispatch routine will be called when a rpc request for this 155 * program number comes in. 156 */ 157bool_t --- 448 unchanged lines hidden (view full) --- 606 enum xprt_stat stat; 607 char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; 608 609 msg.rm_call.cb_cred.oa_base = cred_area; 610 msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); 611 r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); 612 613 rwlock_rdlock(&svc_fd_lock); | 164} 165 166/* 167 * Add a service program to the callout list. 168 * The dispatch routine will be called when a rpc request for this 169 * program number comes in. 170 */ 171bool_t --- 448 unchanged lines hidden (view full) --- 620 enum xprt_stat stat; 621 char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; 622 623 msg.rm_call.cb_cred.oa_base = cred_area; 624 msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); 625 r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); 626 627 rwlock_rdlock(&svc_fd_lock); |
614 xprt = xports[fd]; | 628 xprt = __svc_xports[fd]; |
615 rwlock_unlock(&svc_fd_lock); 616 if (xprt == NULL) 617 /* But do we control sock? */ 618 return; 619 /* now receive msgs from xprtprt (support batch calls) */ 620 do { 621 if (SVC_RECV(xprt, &msg)) { 622 --- 39 unchanged lines hidden (view full) --- 662 /* Fall through to ... */ 663 } 664 /* 665 * Check if the xprt has been disconnected in a 666 * recursive call in the service dispatch routine. 667 * If so, then break. 668 */ 669 rwlock_rdlock(&svc_fd_lock); | 629 rwlock_unlock(&svc_fd_lock); 630 if (xprt == NULL) 631 /* But do we control sock? */ 632 return; 633 /* now receive msgs from xprtprt (support batch calls) */ 634 do { 635 if (SVC_RECV(xprt, &msg)) { 636 --- 39 unchanged lines hidden (view full) --- 676 /* Fall through to ... */ 677 } 678 /* 679 * Check if the xprt has been disconnected in a 680 * recursive call in the service dispatch routine. 681 * If so, then break. 682 */ 683 rwlock_rdlock(&svc_fd_lock); |
670 if (xprt != xports[fd]) { | 684 if (xprt != __svc_xports[fd]) { |
671 rwlock_unlock(&svc_fd_lock); 672 break; 673 } 674 rwlock_unlock(&svc_fd_lock); 675call_done: 676 if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ 677 SVC_DESTROY(xprt); 678 break; --- 31 unchanged lines hidden (view full) --- 710 rwlock_wrlock(&svc_fd_lock); 711 FD_CLR(p->fd, &svc_fdset); 712 rwlock_unlock(&svc_fd_lock); 713 } else 714 svc_getreq_common(p->fd); 715 } 716 } 717} | 685 rwlock_unlock(&svc_fd_lock); 686 break; 687 } 688 rwlock_unlock(&svc_fd_lock); 689call_done: 690 if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ 691 SVC_DESTROY(xprt); 692 break; --- 31 unchanged lines hidden (view full) --- 724 rwlock_wrlock(&svc_fd_lock); 725 FD_CLR(p->fd, &svc_fdset); 726 rwlock_unlock(&svc_fd_lock); 727 } else 728 svc_getreq_common(p->fd); 729 } 730 } 731} |
732 733bool_t 734rpc_control(int what, void *arg) 735{ 736 int val; 737 738 switch (what) { 739 case RPC_SVC_CONNMAXREC_SET: 740 val = *(int *)arg; 741 if (val <= 0) 742 return FALSE; 743 __svc_maxrec = val; 744 return TRUE; 745 case RPC_SVC_CONNMAXREC_GET: 746 *(int *)arg = __svc_maxrec; 747 return TRUE; 748 default: 749 break; 750 } 751 return FALSE; 752} |
|