Deleted Added
full compact
svc_vc.c (217242) svc_vc.c (218757)
1/* $NetBSD: svc_vc.c,v 1.7 2000/08/03 00:01:53 fvdl 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 *sccsid2 = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
34static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
35#endif
36#include <sys/cdefs.h>
1/* $NetBSD: svc_vc.c,v 1.7 2000/08/03 00:01:53 fvdl 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 *sccsid2 = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
34static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
35#endif
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/rpc/svc_vc.c 217242 2011-01-10 21:35:10Z rmacklem $");
37__FBSDID("$FreeBSD: head/sys/rpc/svc_vc.c 218757 2011-02-16 21:29:13Z bz $");
38
39/*
40 * svc_vc.c, Server side for Connection Oriented based RPC.
41 *
42 * Actually implements two flavors of transporter -
43 * a tcp rendezvouser (a listner and connection establisher)
44 * and a record/tcp stream.
45 */

--- 103 unchanged lines hidden (view full) ---

149 xprt = svc_xprt_alloc();
150 sx_init(&xprt->xp_lock, "xprt->xp_lock");
151 xprt->xp_pool = pool;
152 xprt->xp_socket = so;
153 xprt->xp_p1 = NULL;
154 xprt->xp_p2 = NULL;
155 xprt->xp_ops = &svc_vc_rendezvous_ops;
156
38
39/*
40 * svc_vc.c, Server side for Connection Oriented based RPC.
41 *
42 * Actually implements two flavors of transporter -
43 * a tcp rendezvouser (a listner and connection establisher)
44 * and a record/tcp stream.
45 */

--- 103 unchanged lines hidden (view full) ---

149 xprt = svc_xprt_alloc();
150 sx_init(&xprt->xp_lock, "xprt->xp_lock");
151 xprt->xp_pool = pool;
152 xprt->xp_socket = so;
153 xprt->xp_p1 = NULL;
154 xprt->xp_p2 = NULL;
155 xprt->xp_ops = &svc_vc_rendezvous_ops;
156
157 CURVNET_SET(so->so_vnet);
158 error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
159 if (error) {
157 error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
158 if (error) {
160 CURVNET_RESTORE();
161 goto cleanup_svc_vc_create;
162 }
163
164 memcpy(&xprt->xp_ltaddr, sa, sa->sa_len);
165 free(sa, M_SONAME);
166
167 xprt_register(xprt);
168
169 solisten(so, SOMAXCONN, curthread);
159 goto cleanup_svc_vc_create;
160 }
161
162 memcpy(&xprt->xp_ltaddr, sa, sa->sa_len);
163 free(sa, M_SONAME);
164
165 xprt_register(xprt);
166
167 solisten(so, SOMAXCONN, curthread);
170 CURVNET_RESTORE();
171
172 SOCKBUF_LOCK(&so->so_rcv);
173 xprt->xp_upcallset = 1;
174 soupcall_set(so, SO_RCV, svc_vc_soupcall, xprt);
175 SOCKBUF_UNLOCK(&so->so_rcv);
176
177 return (xprt);
178cleanup_svc_vc_create:

--- 16 unchanged lines hidden (view full) ---

195 int error;
196
197 bzero(&opt, sizeof(struct sockopt));
198 opt.sopt_dir = SOPT_SET;
199 opt.sopt_level = SOL_SOCKET;
200 opt.sopt_name = SO_KEEPALIVE;
201 opt.sopt_val = &one;
202 opt.sopt_valsize = sizeof(one);
168
169 SOCKBUF_LOCK(&so->so_rcv);
170 xprt->xp_upcallset = 1;
171 soupcall_set(so, SO_RCV, svc_vc_soupcall, xprt);
172 SOCKBUF_UNLOCK(&so->so_rcv);
173
174 return (xprt);
175cleanup_svc_vc_create:

--- 16 unchanged lines hidden (view full) ---

192 int error;
193
194 bzero(&opt, sizeof(struct sockopt));
195 opt.sopt_dir = SOPT_SET;
196 opt.sopt_level = SOL_SOCKET;
197 opt.sopt_name = SO_KEEPALIVE;
198 opt.sopt_val = &one;
199 opt.sopt_valsize = sizeof(one);
203 CURVNET_SET(so->so_vnet);
204 error = sosetopt(so, &opt);
205 if (error) {
200 error = sosetopt(so, &opt);
201 if (error) {
206 CURVNET_RESTORE();
207 return (NULL);
208 }
209
210 if (so->so_proto->pr_protocol == IPPROTO_TCP) {
211 bzero(&opt, sizeof(struct sockopt));
212 opt.sopt_dir = SOPT_SET;
213 opt.sopt_level = IPPROTO_TCP;
214 opt.sopt_name = TCP_NODELAY;
215 opt.sopt_val = &one;
216 opt.sopt_valsize = sizeof(one);
217 error = sosetopt(so, &opt);
218 if (error) {
202 return (NULL);
203 }
204
205 if (so->so_proto->pr_protocol == IPPROTO_TCP) {
206 bzero(&opt, sizeof(struct sockopt));
207 opt.sopt_dir = SOPT_SET;
208 opt.sopt_level = IPPROTO_TCP;
209 opt.sopt_name = TCP_NODELAY;
210 opt.sopt_val = &one;
211 opt.sopt_valsize = sizeof(one);
212 error = sosetopt(so, &opt);
213 if (error) {
219 CURVNET_RESTORE();
220 return (NULL);
221 }
222 }
214 return (NULL);
215 }
216 }
223 CURVNET_RESTORE();
224
225 cd = mem_alloc(sizeof(*cd));
226 cd->strm_stat = XPRT_IDLE;
227
228 xprt = svc_xprt_alloc();
229 sx_init(&xprt->xp_lock, "xprt->xp_lock");
230 xprt->xp_pool = pool;
231 xprt->xp_socket = so;

--- 398 unchanged lines hidden (view full) ---

630 * the result in cd->mpending. If the read fails,
631 * we have drained both cd->mpending and the socket so
632 * we can call xprt_inactive().
633 */
634 uio.uio_resid = 1000000000;
635 uio.uio_td = curthread;
636 m = NULL;
637 rcvflag = MSG_DONTWAIT;
217
218 cd = mem_alloc(sizeof(*cd));
219 cd->strm_stat = XPRT_IDLE;
220
221 xprt = svc_xprt_alloc();
222 sx_init(&xprt->xp_lock, "xprt->xp_lock");
223 xprt->xp_pool = pool;
224 xprt->xp_socket = so;

--- 398 unchanged lines hidden (view full) ---

623 * the result in cd->mpending. If the read fails,
624 * we have drained both cd->mpending and the socket so
625 * we can call xprt_inactive().
626 */
627 uio.uio_resid = 1000000000;
628 uio.uio_td = curthread;
629 m = NULL;
630 rcvflag = MSG_DONTWAIT;
638 CURVNET_SET(xprt->xp_socket->so_vnet);
639 error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL,
640 &rcvflag);
631 error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL,
632 &rcvflag);
641 CURVNET_RESTORE();
642
643 if (error == EWOULDBLOCK) {
644 /*
645 * We must re-test for readability after
646 * taking the lock to protect us in the case
647 * where a new packet arrives on the socket
648 * after our call to soreceive fails with
649 * EWOULDBLOCK. The pool lock protects us from

--- 133 unchanged lines hidden ---
633
634 if (error == EWOULDBLOCK) {
635 /*
636 * We must re-test for readability after
637 * taking the lock to protect us in the case
638 * where a new packet arrives on the socket
639 * after our call to soreceive fails with
640 * EWOULDBLOCK. The pool lock protects us from

--- 133 unchanged lines hidden ---