Deleted Added
full compact
uipc_sockbuf.c (130513) uipc_sockbuf.c (130653)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 130513 2004-06-15 03:51:44Z rwatson $");
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 130653 2004-06-17 22:48:11Z rwatson $");
34
35#include "opt_mac.h"
36#include "opt_param.h"
37
38#include <sys/param.h>
39#include <sys/aio.h> /* for aio_swake proto */
40#include <sys/domain.h>
41#include <sys/event.h>

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

100 * cause software-interrupt process scheduling.
101 */
102
103void
104soisconnecting(so)
105 register struct socket *so;
106{
107
34
35#include "opt_mac.h"
36#include "opt_param.h"
37
38#include <sys/param.h>
39#include <sys/aio.h> /* for aio_swake proto */
40#include <sys/domain.h>
41#include <sys/event.h>

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

100 * cause software-interrupt process scheduling.
101 */
102
103void
104soisconnecting(so)
105 register struct socket *so;
106{
107
108 SOCK_LOCK(so);
108 so->so_state &= ~(SS_ISCONNECTED|SS_ISDISCONNECTING);
109 so->so_state |= SS_ISCONNECTING;
109 so->so_state &= ~(SS_ISCONNECTED|SS_ISDISCONNECTING);
110 so->so_state |= SS_ISCONNECTING;
111 SOCK_UNLOCK(so);
110}
111
112void
113soisconnected(so)
114 struct socket *so;
115{
116 struct socket *head;
117
112}
113
114void
115soisconnected(so)
116 struct socket *so;
117{
118 struct socket *head;
119
120 SOCK_LOCK(so);
118 so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING);
119 so->so_state |= SS_ISCONNECTED;
121 so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING);
122 so->so_state |= SS_ISCONNECTED;
123 SOCK_UNLOCK(so);
120 ACCEPT_LOCK();
121 head = so->so_head;
122 if (head != NULL && (so->so_qstate & SQ_INCOMP)) {
123 if ((so->so_options & SO_ACCEPTFILTER) == 0) {
124 TAILQ_REMOVE(&head->so_incomp, so, so_list);
125 head->so_incqlen--;
126 so->so_qstate &= ~SQ_INCOMP;
127 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
128 head->so_qlen++;
129 so->so_qstate |= SQ_COMP;
130 ACCEPT_UNLOCK();
131 sorwakeup(head);
132 wakeup_one(&head->so_timeo);
133 } else {
134 ACCEPT_UNLOCK();
124 ACCEPT_LOCK();
125 head = so->so_head;
126 if (head != NULL && (so->so_qstate & SQ_INCOMP)) {
127 if ((so->so_options & SO_ACCEPTFILTER) == 0) {
128 TAILQ_REMOVE(&head->so_incomp, so, so_list);
129 head->so_incqlen--;
130 so->so_qstate &= ~SQ_INCOMP;
131 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
132 head->so_qlen++;
133 so->so_qstate |= SQ_COMP;
134 ACCEPT_UNLOCK();
135 sorwakeup(head);
136 wakeup_one(&head->so_timeo);
137 } else {
138 ACCEPT_UNLOCK();
139 SOCK_LOCK(so);
135 so->so_upcall =
136 head->so_accf->so_accept_filter->accf_callback;
137 so->so_upcallarg = head->so_accf->so_accept_filter_arg;
138 so->so_rcv.sb_flags |= SB_UPCALL;
139 so->so_options &= ~SO_ACCEPTFILTER;
140 so->so_upcall =
141 head->so_accf->so_accept_filter->accf_callback;
142 so->so_upcallarg = head->so_accf->so_accept_filter_arg;
143 so->so_rcv.sb_flags |= SB_UPCALL;
144 so->so_options &= ~SO_ACCEPTFILTER;
145 SOCK_UNLOCK(so);
140 so->so_upcall(so, so->so_upcallarg, M_TRYWAIT);
141 }
142 return;
143 }
144 ACCEPT_UNLOCK();
145 wakeup(&so->so_timeo);
146 sorwakeup(so);
147 sowwakeup(so);
148}
149
150void
151soisdisconnecting(so)
152 register struct socket *so;
153{
154
146 so->so_upcall(so, so->so_upcallarg, M_TRYWAIT);
147 }
148 return;
149 }
150 ACCEPT_UNLOCK();
151 wakeup(&so->so_timeo);
152 sorwakeup(so);
153 sowwakeup(so);
154}
155
156void
157soisdisconnecting(so)
158 register struct socket *so;
159{
160
161 /*
162 * XXXRW: This code separately acquires SOCK_LOCK(so) and
163 * SOCKBUF_LOCK(&so->so_rcv) even though they are the same mutex to
164 * avoid introducing the assumption that they are the same.
165 */
166 SOCK_LOCK(so);
155 so->so_state &= ~SS_ISCONNECTING;
156 so->so_state |= SS_ISDISCONNECTING;
167 so->so_state &= ~SS_ISCONNECTING;
168 so->so_state |= SS_ISDISCONNECTING;
169 SOCK_UNLOCK(so);
157 SOCKBUF_LOCK(&so->so_rcv);
158 so->so_rcv.sb_state |= SBS_CANTRCVMORE;
159 SOCKBUF_UNLOCK(&so->so_rcv);
160 SOCKBUF_LOCK(&so->so_snd);
161 so->so_snd.sb_state |= SBS_CANTSENDMORE;
162 SOCKBUF_UNLOCK(&so->so_snd);
163 wakeup(&so->so_timeo);
164 sowwakeup(so);
165 sorwakeup(so);
166}
167
168void
169soisdisconnected(so)
170 register struct socket *so;
171{
172
170 SOCKBUF_LOCK(&so->so_rcv);
171 so->so_rcv.sb_state |= SBS_CANTRCVMORE;
172 SOCKBUF_UNLOCK(&so->so_rcv);
173 SOCKBUF_LOCK(&so->so_snd);
174 so->so_snd.sb_state |= SBS_CANTSENDMORE;
175 SOCKBUF_UNLOCK(&so->so_snd);
176 wakeup(&so->so_timeo);
177 sowwakeup(so);
178 sorwakeup(so);
179}
180
181void
182soisdisconnected(so)
183 register struct socket *so;
184{
185
186 /*
187 * XXXRW: This code separately acquires SOCK_LOCK(so) and
188 * SOCKBUF_LOCK(&so->so_rcv) even though they are the same mutex to
189 * avoid introducing the assumption that they are the same.
190 */
191 SOCK_LOCK(so);
173 so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
174 so->so_state |= SS_ISDISCONNECTED;
192 so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
193 so->so_state |= SS_ISDISCONNECTED;
194 SOCK_UNLOCK(so);
175 SOCKBUF_LOCK(&so->so_rcv);
176 so->so_rcv.sb_state |= SBS_CANTRCVMORE;
177 SOCKBUF_UNLOCK(&so->so_rcv);
178 SOCKBUF_LOCK(&so->so_snd);
179 so->so_snd.sb_state |= SBS_CANTSENDMORE;
180 SOCKBUF_UNLOCK(&so->so_snd);
181 wakeup(&so->so_timeo);
182 sbdrop(&so->so_snd, so->so_snd.sb_cc);

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

395 u_long sndcc, rcvcc;
396{
397 struct thread *td = curthread;
398
399 if (sbreserve(&so->so_snd, sndcc, so, td) == 0)
400 goto bad;
401 if (sbreserve(&so->so_rcv, rcvcc, so, td) == 0)
402 goto bad2;
195 SOCKBUF_LOCK(&so->so_rcv);
196 so->so_rcv.sb_state |= SBS_CANTRCVMORE;
197 SOCKBUF_UNLOCK(&so->so_rcv);
198 SOCKBUF_LOCK(&so->so_snd);
199 so->so_snd.sb_state |= SBS_CANTSENDMORE;
200 SOCKBUF_UNLOCK(&so->so_snd);
201 wakeup(&so->so_timeo);
202 sbdrop(&so->so_snd, so->so_snd.sb_cc);

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

415 u_long sndcc, rcvcc;
416{
417 struct thread *td = curthread;
418
419 if (sbreserve(&so->so_snd, sndcc, so, td) == 0)
420 goto bad;
421 if (sbreserve(&so->so_rcv, rcvcc, so, td) == 0)
422 goto bad2;
423 SOCKBUF_LOCK(&so->so_rcv);
403 if (so->so_rcv.sb_lowat == 0)
404 so->so_rcv.sb_lowat = 1;
424 if (so->so_rcv.sb_lowat == 0)
425 so->so_rcv.sb_lowat = 1;
426 SOCKBUF_UNLOCK(&so->so_rcv);
427 SOCKBUF_LOCK(&so->so_snd);
405 if (so->so_snd.sb_lowat == 0)
406 so->so_snd.sb_lowat = MCLBYTES;
407 if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat)
408 so->so_snd.sb_lowat = so->so_snd.sb_hiwat;
428 if (so->so_snd.sb_lowat == 0)
429 so->so_snd.sb_lowat = MCLBYTES;
430 if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat)
431 so->so_snd.sb_lowat = so->so_snd.sb_hiwat;
432 SOCKBUF_UNLOCK(&so->so_snd);
409 return (0);
410bad2:
411 sbrelease(&so->so_snd, so);
412bad:
413 return (ENOBUFS);
414}
415
416static int

--- 759 unchanged lines hidden ---
433 return (0);
434bad2:
435 sbrelease(&so->so_snd, so);
436bad:
437 return (ENOBUFS);
438}
439
440static int

--- 759 unchanged lines hidden ---