diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-05-20 05:41:09 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-05-20 05:41:09 +0000 |
commit | 92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 (patch) | |
tree | 2465ddbcecac65f96c5c6d5cef1a4fe3f1ac03f8 /sys/net/rtsock.c | |
parent | 969293170b27461145f69a538d5abd15fea34ba1 (diff) | |
download | FreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.zip FreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.tar.gz |
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
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r-- | sys/net/rtsock.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 47031c2..407d6f3 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -147,8 +147,10 @@ rts_attach(struct socket *so, int proto, struct thread *td) } rp->rcb_faddr = &route_src; route_cb.any_count++; - soisconnected_locked(so); + SOCK_LOCK(so); + soisconnected(so); so->so_options |= SO_USELOOPBACK; + SOCK_UNLOCK(so); splx(s); return 0; } @@ -472,7 +474,9 @@ flush: /* * Check to see if we don't want our own messages. */ + SOCK_LOCK(so); if ((so->so_options & SO_USELOOPBACK) == 0) { + SOCK_UNLOCK(so); if (route_cb.any_count <= 1) { if (rtm) Free(rtm); @@ -481,7 +485,8 @@ flush: } /* There is another listener, so construct message */ rp = sotorawcb(so); - } + } else + SOCK_UNLOCK(so); if (rtm) { m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm); if (m->m_pkthdr.len < rtm->rtm_msglen) { |