From 92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 Mon Sep 17 00:00:00 2001 From: tanimura Date: Mon, 20 May 2002 05:41:09 +0000 Subject: Lock down a socket, milestone 1. o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a socket buffer. The mutex in the receive buffer also protects the data in struct socket. o Determine the lock strategy for each members in struct socket. o Lock down the following members: - so_count - so_options - so_linger - so_state o Remove *_locked() socket APIs. Make the following socket APIs touching the members above now require a locked socket: - sodisconnect() - soisconnected() - soisconnecting() - soisdisconnected() - soisdisconnecting() - sofree() - soref() - sorele() - sorwakeup() - sotryfree() - sowakeup() - sowwakeup() Reviewed by: alfred --- sys/net/raw_usrreq.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sys/net/raw_usrreq.c') diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 7afab70..631b2e8 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -105,7 +106,9 @@ raw_input(m0, proto, src, dst) /* should notify about lost packet */ m_freem(n); else { + SOCK_LOCK(last); sorwakeup(last); + SOCK_UNLOCK(last); sockets++; } } @@ -117,7 +120,9 @@ raw_input(m0, proto, src, dst) m, (struct mbuf *)0) == 0) m_freem(m); else { + SOCK_LOCK(last); sorwakeup(last); + SOCK_UNLOCK(last); sockets++; } } else @@ -145,8 +150,11 @@ raw_uabort(struct socket *so) if (rp == 0) return EINVAL; raw_disconnect(rp); + SOCK_LOCK(so); sotryfree(so); + SOCK_LOCK(so); soisdisconnected(so); /* XXX huh? called after the sofree()? */ + SOCK_UNLOCK(so); return 0; } @@ -203,7 +211,9 @@ raw_udisconnect(struct socket *so) return ENOTCONN; } raw_disconnect(rp); + SOCK_LOCK(so); soisdisconnected(so); + SOCK_UNLOCK(so); return 0; } -- cgit v1.1