Deleted Added
sdiff udiff text old ( 130480 ) new ( 130653 )
full compact
1/*
2 * Copyright (c) 1982, 1986, 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 * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/sys_socket.c 130653 2004-06-17 22:48:11Z rwatson $");
34
35#include "opt_mac.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/file.h>
40#include <sys/filedesc.h>
41#include <sys/mac.h>

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

126 struct ucred *active_cred;
127 struct thread *td;
128{
129 register struct socket *so = fp->f_data;
130
131 switch (cmd) {
132
133 case FIONBIO:
134 SOCK_LOCK(so);
135 if (*(int *)data)
136 so->so_state |= SS_NBIO;
137 else
138 so->so_state &= ~SS_NBIO;
139 SOCK_UNLOCK(so);
140 return (0);
141
142 case FIOASYNC:
143 /*
144 * XXXRW: This code separately acquires SOCK_LOCK(so)
145 * and SOCKBUF_LOCK(&so->so_rcv) even though they are
146 * the same mutex to avoid introducing the assumption
147 * that they are the same.
148 */
149 if (*(int *)data) {
150 SOCK_LOCK(so);
151 so->so_state |= SS_ASYNC;
152 SOCK_UNLOCK(so);
153 SOCKBUF_LOCK(&so->so_rcv);
154 so->so_rcv.sb_flags |= SB_ASYNC;
155 SOCKBUF_UNLOCK(&so->so_rcv);
156 SOCKBUF_LOCK(&so->so_snd);
157 so->so_snd.sb_flags |= SB_ASYNC;
158 SOCKBUF_UNLOCK(&so->so_snd);
159 } else {
160 SOCK_LOCK(so);
161 so->so_state &= ~SS_ASYNC;
162 SOCK_UNLOCK(so);
163 SOCKBUF_LOCK(&so->so_rcv);
164 so->so_rcv.sb_flags &= ~SB_ASYNC;
165 SOCKBUF_UNLOCK(&so->so_rcv);
166 SOCKBUF_LOCK(&so->so_snd);
167 so->so_snd.sb_flags &= ~SB_ASYNC;
168 SOCKBUF_UNLOCK(&so->so_snd);
169 }
170 return (0);
171
172 case FIONREAD:
173 *(int *)data = so->so_rcv.sb_cc;
174 return (0);
175
176 case FIOSETOWN:

--- 90 unchanged lines hidden ---