Deleted Added
full compact
uipc_sockbuf.c (13267) uipc_sockbuf.c (14547)
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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
34 * $Id: uipc_socket2.c,v 1.7 1995/12/14 22:51:02 bde Exp $
34 * $Id: uipc_socket2.c,v 1.8 1996/01/05 21:41:54 wollman Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/proc.h>
41#include <sys/file.h>
42#include <sys/buf.h>

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

102void
103soisconnected(so)
104 register struct socket *so;
105{
106 register struct socket *head = so->so_head;
107
108 so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING);
109 so->so_state |= SS_ISCONNECTED;
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/proc.h>
41#include <sys/file.h>
42#include <sys/buf.h>

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

102void
103soisconnected(so)
104 register struct socket *so;
105{
106 register struct socket *head = so->so_head;
107
108 so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING);
109 so->so_state |= SS_ISCONNECTED;
110 if (head && soqremque(so, 0)) {
111 soqinsque(head, so, 1);
110 if (head && (so->so_state & SS_INCOMP)) {
111 TAILQ_REMOVE(&head->so_incomp, so, so_list);
112 so->so_state &= ~SS_INCOMP;
113 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
114 so->so_state |= SS_COMP;
112 sorwakeup(head);
113 wakeup((caddr_t)&head->so_timeo);
114 } else {
115 wakeup((caddr_t)&so->so_timeo);
116 sorwakeup(so);
117 sowwakeup(so);
118 }
119}

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

156struct socket *
157sonewconn1(head, connstatus)
158 register struct socket *head;
159 int connstatus;
160{
161 register struct socket *so;
162 int soqueue = connstatus ? 1 : 0;
163
115 sorwakeup(head);
116 wakeup((caddr_t)&head->so_timeo);
117 } else {
118 wakeup((caddr_t)&so->so_timeo);
119 sorwakeup(so);
120 sowwakeup(so);
121 }
122}

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

159struct socket *
160sonewconn1(head, connstatus)
161 register struct socket *head;
162 int connstatus;
163{
164 register struct socket *so;
165 int soqueue = connstatus ? 1 : 0;
166
164 if (head->so_qlen + head->so_q0len > 3 * head->so_qlimit / 2)
167 if (head->so_qlen > 3 * head->so_qlimit / 2)
165 return ((struct socket *)0);
166 MALLOC(so, struct socket *, sizeof(*so), M_SOCKET, M_DONTWAIT);
167 if (so == NULL)
168 return ((struct socket *)0);
169 bzero((caddr_t)so, sizeof(*so));
168 return ((struct socket *)0);
169 MALLOC(so, struct socket *, sizeof(*so), M_SOCKET, M_DONTWAIT);
170 if (so == NULL)
171 return ((struct socket *)0);
172 bzero((caddr_t)so, sizeof(*so));
173 so->so_head = head;
170 so->so_type = head->so_type;
171 so->so_options = head->so_options &~ SO_ACCEPTCONN;
172 so->so_linger = head->so_linger;
173 so->so_state = head->so_state | SS_NOFDREF;
174 so->so_proto = head->so_proto;
175 so->so_timeo = head->so_timeo;
176 so->so_pgid = head->so_pgid;
177 (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
174 so->so_type = head->so_type;
175 so->so_options = head->so_options &~ SO_ACCEPTCONN;
176 so->so_linger = head->so_linger;
177 so->so_state = head->so_state | SS_NOFDREF;
178 so->so_proto = head->so_proto;
179 so->so_timeo = head->so_timeo;
180 so->so_pgid = head->so_pgid;
181 (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
178 soqinsque(head, so, soqueue);
182 if (connstatus) {
183 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
184 so->so_state |= SS_COMP;
185 } else {
186 TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list);
187 so->so_state |= SS_INCOMP;
188 }
189 head->so_qlen++;
179 if ((*so->so_proto->pr_usrreq)(so, PRU_ATTACH,
180 (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0)) {
190 if ((*so->so_proto->pr_usrreq)(so, PRU_ATTACH,
191 (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0)) {
181 (void) soqremque(so, soqueue);
192 if (so->so_state & SS_COMP) {
193 TAILQ_REMOVE(&head->so_comp, so, so_list);
194 } else {
195 TAILQ_REMOVE(&head->so_incomp, so, so_list);
196 }
197 head->so_qlen--;
182 (void) free((caddr_t)so, M_SOCKET);
183 return ((struct socket *)0);
184 }
185 if (connstatus) {
186 sorwakeup(head);
187 wakeup((caddr_t)&head->so_timeo);
188 so->so_state |= connstatus;
189 }
190 return (so);
191}
192
198 (void) free((caddr_t)so, M_SOCKET);
199 return ((struct socket *)0);
200 }
201 if (connstatus) {
202 sorwakeup(head);
203 wakeup((caddr_t)&head->so_timeo);
204 so->so_state |= connstatus;
205 }
206 return (so);
207}
208
193void
194soqinsque(head, so, q)
195 register struct socket *head, *so;
196 int q;
197{
198
199 register struct socket **prev;
200 so->so_head = head;
201 if (q == 0) {
202 head->so_q0len++;
203 so->so_q0 = 0;
204 for (prev = &(head->so_q0); *prev; )
205 prev = &((*prev)->so_q0);
206 } else {
207 head->so_qlen++;
208 so->so_q = 0;
209 for (prev = &(head->so_q); *prev; )
210 prev = &((*prev)->so_q);
211 }
212 *prev = so;
213}
214
215int
216soqremque(so, q)
217 register struct socket *so;
218 int q;
219{
220 register struct socket *head, *prev, *next;
221
222 head = so->so_head;
223 prev = head;
224 for (;;) {
225 next = q ? prev->so_q : prev->so_q0;
226 if (next == so)
227 break;
228 if (next == 0)
229 return (0);
230 prev = next;
231 }
232 if (q == 0) {
233 prev->so_q0 = next->so_q0;
234 head->so_q0len--;
235 } else {
236 prev->so_q = next->so_q;
237 head->so_qlen--;
238 }
239 next->so_q0 = next->so_q = 0;
240 next->so_head = 0;
241 return (1);
242}
243
244/*
245 * Socantsendmore indicates that no more data will be sent on the
246 * socket; it would normally be applied to a socket when the user
247 * informs the system that no more data is to be sent, by the protocol
248 * code (in case PRU_SHUTDOWN). Socantrcvmore indicates that no more data
249 * will be received, and will normally be applied to the socket by a
250 * protocol when it detects that the peer will send no more data.
251 * Data queued for reading in the socket may yet be read.

--- 541 unchanged lines hidden ---
209/*
210 * Socantsendmore indicates that no more data will be sent on the
211 * socket; it would normally be applied to a socket when the user
212 * informs the system that no more data is to be sent, by the protocol
213 * code (in case PRU_SHUTDOWN). Socantrcvmore indicates that no more data
214 * will be received, and will normally be applied to the socket by a
215 * protocol when it detects that the peer will send no more data.
216 * Data queued for reading in the socket may yet be read.

--- 541 unchanged lines hidden ---