Deleted Added
full compact
uipc_syscalls.c (14232) uipc_syscalls.c (14547)
1/*
2 * Copyright (c) 1982, 1986, 1989, 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_syscalls.c 8.4 (Berkeley) 2/21/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 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_syscalls.c 8.4 (Berkeley) 2/21/94
34 * $Id: uipc_syscalls.c,v 1.14 1996/02/13 18:16:21 wollman Exp $
34 * $Id: uipc_syscalls.c,v 1.15 1996/02/24 13:38:07 phk Exp $
35 */
36
37#include "opt_ktrace.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/sysproto.h>
42#include <sys/filedesc.h>

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

162 int *anamelen;
163 } */ *uap;
164 int *retval;
165 int compat;
166{
167 struct file *fp;
168 struct mbuf *nam;
169 int namelen, error, s;
35 */
36
37#include "opt_ktrace.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/sysproto.h>
42#include <sys/filedesc.h>

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

162 int *anamelen;
163 } */ *uap;
164 int *retval;
165 int compat;
166{
167 struct file *fp;
168 struct mbuf *nam;
169 int namelen, error, s;
170 register struct socket *so;
170 struct socket *head, *so;
171
172 if (uap->name) {
173 error = copyin((caddr_t)uap->anamelen, (caddr_t)&namelen,
174 sizeof (namelen));
175 if(error)
176 return (error);
177 }
178 error = getsock(p->p_fd, uap->s, &fp);
179 if (error)
180 return (error);
181 s = splnet();
171
172 if (uap->name) {
173 error = copyin((caddr_t)uap->anamelen, (caddr_t)&namelen,
174 sizeof (namelen));
175 if(error)
176 return (error);
177 }
178 error = getsock(p->p_fd, uap->s, &fp);
179 if (error)
180 return (error);
181 s = splnet();
182 so = (struct socket *)fp->f_data;
183 if ((so->so_options & SO_ACCEPTCONN) == 0) {
182 head = (struct socket *)fp->f_data;
183 if ((head->so_options & SO_ACCEPTCONN) == 0) {
184 splx(s);
185 return (EINVAL);
186 }
184 splx(s);
185 return (EINVAL);
186 }
187 if ((so->so_state & SS_NBIO) && so->so_qlen == 0) {
187 if ((head->so_state & SS_NBIO) && head->so_comp.tqh_first == NULL) {
188 splx(s);
189 return (EWOULDBLOCK);
190 }
188 splx(s);
189 return (EWOULDBLOCK);
190 }
191 while (so->so_qlen == 0 && so->so_error == 0) {
192 if (so->so_state & SS_CANTRCVMORE) {
193 so->so_error = ECONNABORTED;
191 while (head->so_comp.tqh_first == NULL && head->so_error == 0) {
192 if (head->so_state & SS_CANTRCVMORE) {
193 head->so_error = ECONNABORTED;
194 break;
195 }
194 break;
195 }
196 error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
196 error = tsleep((caddr_t)&head->so_timeo, PSOCK | PCATCH,
197 "accept", 0);
198 if (error) {
199 splx(s);
200 return (error);
201 }
202 }
197 "accept", 0);
198 if (error) {
199 splx(s);
200 return (error);
201 }
202 }
203 if (so->so_error) {
204 error = so->so_error;
205 so->so_error = 0;
203 if (head->so_error) {
204 error = head->so_error;
205 head->so_error = 0;
206 splx(s);
207 return (error);
208 }
209 error = falloc(p, &fp, retval);
210 if (error) {
211 splx(s);
212 return (error);
213 }
206 splx(s);
207 return (error);
208 }
209 error = falloc(p, &fp, retval);
210 if (error) {
211 splx(s);
212 return (error);
213 }
214 { struct socket *aso = so->so_q;
215 if (soqremque(aso, 1) == 0)
216 panic("accept");
217 so = aso;
218 }
214
215 so = head->so_comp.tqh_first;
216 if (so == NULL)
217 panic("accept: nothing queued");
218 TAILQ_REMOVE(&head->so_comp, so, so_list);
219 so->so_state &= ~SS_COMP;
220 so->so_head = NULL;
221 head->so_qlen--;
222
219 fp->f_type = DTYPE_SOCKET;
220 fp->f_flag = FREAD|FWRITE;
221 fp->f_ops = &socketops;
222 fp->f_data = (caddr_t)so;
223 nam = m_get(M_WAIT, MT_SONAME);
224 (void) soaccept(so, nam);
225 if (uap->name) {
226#ifdef COMPAT_OLDSOCK

--- 1056 unchanged lines hidden ---
223 fp->f_type = DTYPE_SOCKET;
224 fp->f_flag = FREAD|FWRITE;
225 fp->f_ops = &socketops;
226 fp->f_data = (caddr_t)so;
227 nam = m_get(M_WAIT, MT_SONAME);
228 (void) soaccept(so, nam);
229 if (uap->name) {
230#ifdef COMPAT_OLDSOCK

--- 1056 unchanged lines hidden ---