Deleted Added
full compact
socketvar.h (136326) socketvar.h (136682)
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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
30 * $FreeBSD: head/sys/sys/socketvar.h 136326 2004-10-09 16:42:57Z rwatson $
30 * $FreeBSD: head/sys/sys/socketvar.h 136682 2004-10-18 22:19:43Z rwatson $
31 */
32
33#ifndef _SYS_SOCKETVAR_H_
34#define _SYS_SOCKETVAR_H_
35
36#include <sys/queue.h> /* for TAILQ macros */
37#include <sys/selinfo.h> /* for struct selinfo */
38#include <sys/_lock.h>

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

153
154/*
155 * Global accept mutex to serialize access to accept queues and
156 * fields associated with multiple sockets. This allows us to
157 * avoid defining a lock order between listen and accept sockets
158 * until such time as it proves to be a good idea.
159 */
160extern struct mtx accept_mtx;
31 */
32
33#ifndef _SYS_SOCKETVAR_H_
34#define _SYS_SOCKETVAR_H_
35
36#include <sys/queue.h> /* for TAILQ macros */
37#include <sys/selinfo.h> /* for struct selinfo */
38#include <sys/_lock.h>

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

153
154/*
155 * Global accept mutex to serialize access to accept queues and
156 * fields associated with multiple sockets. This allows us to
157 * avoid defining a lock order between listen and accept sockets
158 * until such time as it proves to be a good idea.
159 */
160extern struct mtx accept_mtx;
161#define ACCEPT_LOCK_ASSERT() mtx_assert(&accept_mtx, MA_OWNED)
162#define ACCEPT_UNLOCK_ASSERT() mtx_assert(&accept_mtx, MA_NOTOWNED)
161#define ACCEPT_LOCK() mtx_lock(&accept_mtx)
162#define ACCEPT_UNLOCK() mtx_unlock(&accept_mtx)
163
164/*
165 * Per-socket buffer mutex used to protect most fields in the socket
166 * buffer.
167 */
168#define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)

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

339 * the structure.
340 */
341#define soref(so) do { \
342 SOCK_LOCK_ASSERT(so); \
343 ++(so)->so_count; \
344} while (0)
345
346#define sorele(so) do { \
163#define ACCEPT_LOCK() mtx_lock(&accept_mtx)
164#define ACCEPT_UNLOCK() mtx_unlock(&accept_mtx)
165
166/*
167 * Per-socket buffer mutex used to protect most fields in the socket
168 * buffer.
169 */
170#define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)

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

341 * the structure.
342 */
343#define soref(so) do { \
344 SOCK_LOCK_ASSERT(so); \
345 ++(so)->so_count; \
346} while (0)
347
348#define sorele(so) do { \
349 ACCEPT_LOCK_ASSERT(); \
347 SOCK_LOCK_ASSERT(so); \
348 if ((so)->so_count <= 0) \
349 panic("sorele"); \
350 if (--(so)->so_count == 0) \
351 sofree(so); \
350 SOCK_LOCK_ASSERT(so); \
351 if ((so)->so_count <= 0) \
352 panic("sorele"); \
353 if (--(so)->so_count == 0) \
354 sofree(so); \
352 else \
355 else { \
353 SOCK_UNLOCK(so); \
356 SOCK_UNLOCK(so); \
357 ACCEPT_UNLOCK(); \
358 } \
354} while (0)
355
356#define sotryfree(so) do { \
359} while (0)
360
361#define sotryfree(so) do { \
362 ACCEPT_LOCK_ASSERT(); \
357 SOCK_LOCK_ASSERT(so); \
358 if ((so)->so_count == 0) \
359 sofree(so); \
363 SOCK_LOCK_ASSERT(so); \
364 if ((so)->so_count == 0) \
365 sofree(so); \
360 else \
366 else { \
361 SOCK_UNLOCK(so); \
367 SOCK_UNLOCK(so); \
368 ACCEPT_UNLOCK(); \
369 } \
362} while(0)
363
364/*
365 * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
366 * avoid a non-atomic test-and-wakeup. However, sowakeup is
367 * responsible for releasing the lock if it is called. We unlock only
368 * if we don't call into sowakeup. If any code is introduced that
369 * directly invokes the underlying sowakeup() primitives, it must

--- 188 unchanged lines hidden ---
370} while(0)
371
372/*
373 * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
374 * avoid a non-atomic test-and-wakeup. However, sowakeup is
375 * responsible for releasing the lock if it is called. We unlock only
376 * if we don't call into sowakeup. If any code is introduced that
377 * directly invokes the underlying sowakeup() primitives, it must

--- 188 unchanged lines hidden ---