Deleted Added
sdiff udiff text old ( 217242 ) new ( 218757 )
full compact
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 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
157 error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
158 if (error) {
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);
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);
200 error = sosetopt(so, &opt);
201 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) {
214 return (NULL);
215 }
216 }
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;
631 error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL,
632 &rcvflag);
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 ---