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/compat | |
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/compat')
-rw-r--r-- | sys/compat/svr4/svr4_filio.c | 16 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_ioctl.c | 17 |
2 files changed, 23 insertions, 10 deletions
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c index ef9b8b6..5527716 100644 --- a/sys/compat/svr4/svr4_filio.c +++ b/sys/compat/svr4/svr4_filio.c @@ -116,15 +116,17 @@ svr4_sys_read(td, uap) if (fp->f_type == DTYPE_SOCKET) { so = (struct socket *)fp->f_data; - DPRINTF(("fd %d is a socket\n", SCARG(uap, fd))); - if (so->so_state & SS_ASYNC) { - DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd))); - } - DPRINTF(("Here are its flags: 0x%x\n", so->so_state)); -#if defined(GROTTY_READ_HACK) + SOCK_LOCK(so); so_state = so->so_state; +#if defined(GROTTY_READ_HACK) so->so_state &= ~SS_NBIO; #endif + SOCK_UNLOCK(so); + DPRINTF(("fd %d is a socket\n", SCARG(uap, fd))); + if (so_state & SS_ASYNC) { + DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd))); + } + DPRINTF(("Here are its flags: 0x%x\n", so_state)); } rv = read(td, &ra); @@ -140,7 +142,9 @@ svr4_sys_read(td, uap) #if defined(GROTTY_READ_HACK) if (so) { /* We've already checked to see if this is a socket */ + SOCK_LOCK(so); so->so_state = so_state; + SOCK_UNLOCK(so); } #endif fdrop(fp, td); diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c index 50d28ee..d84e89c 100644 --- a/sys/compat/svr4/svr4_ioctl.c +++ b/sys/compat/svr4/svr4_ioctl.c @@ -29,10 +29,12 @@ */ #include <sys/param.h> -#include <sys/proc.h> +#include <sys/fcntl.h> #include <sys/file.h> #include <sys/filedesc.h> -#include <sys/fcntl.h> +#include <sys/lock.h> +#include <sys/proc.h> +#include <sys/mutex.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/systm.h> @@ -93,6 +95,7 @@ svr4_sys_ioctl(td, uap) char c; int num; int argsiz; + int sostate; svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz); @@ -113,7 +116,10 @@ svr4_sys_ioctl(td, uap) #if defined(DEBUG_SVR4) if (fp->f_type == DTYPE_SOCKET) { struct socket *so = (struct socket *)fp->f_data; - DPRINTF(("<<< IN: so_state = 0x%x\n", so->so_state)); + SOCK_LOCK(so); + sostate = so->so_state; + SOCK_UNLOCK(so); + DPRINTF(("<<< IN: so_state = 0x%x\n", sostate)); } #endif @@ -158,7 +164,10 @@ svr4_sys_ioctl(td, uap) struct socket *so; so = (struct socket *)fp->f_data; - DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state)); + SOCK_LOCK(so); + sostate = so->so_state; + SOCK_UNLOCK(so); + DPRINTF((">>> OUT: so_state = 0x%x\n", sostate)); } #endif error = (*fun)(fp, td, retval, SCARG(uap, fd), cmd, SCARG(uap, data)); |