summaryrefslogtreecommitdiffstats
path: root/sys/fs/portalfs
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
committertanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
commit92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 (patch)
tree2465ddbcecac65f96c5c6d5cef1a4fe3f1ac03f8 /sys/fs/portalfs
parent969293170b27461145f69a538d5abd15fea34ba1 (diff)
downloadFreeBSD-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/fs/portalfs')
-rw-r--r--sys/fs/portalfs/portal_vnops.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/sys/fs/portalfs/portal_vnops.c b/sys/fs/portalfs/portal_vnops.c
index b345c57..23b471f 100644
--- a/sys/fs/portalfs/portal_vnops.c
+++ b/sys/fs/portalfs/portal_vnops.c
@@ -43,24 +43,26 @@
*/
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
#include <sys/fcntl.h>
#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
#include <sys/malloc.h>
-#include <sys/namei.h>
#include <sys/mbuf.h>
+#include <sys/mount.h>
+#include <sys/mutex.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/systm.h>
+#include <sys/sysproto.h>
+#include <sys/time.h>
#include <sys/un.h>
#include <sys/unpcb.h>
+#include <sys/vnode.h>
#include <fs/portalfs/portal.h>
static int portal_fileid = PORTAL_ROOTFILEID+1;
@@ -182,8 +184,12 @@ portal_connect(so, so2)
if (so->so_type != so2->so_type)
return (EPROTOTYPE);
- if ((so2->so_options & SO_ACCEPTCONN) == 0)
+ SOCK_LOCK(so2);
+ if ((so2->so_options & SO_ACCEPTCONN) == 0) {
+ SOCK_UNLOCK(so2);
return (ECONNREFUSED);
+ }
+ SOCK_UNLOCK(so2);
if ((so3 = sonewconn(so2, 0)) == 0)
return (ECONNREFUSED);
@@ -280,14 +286,17 @@ portal_open(ap)
* and keep polling the reference count. XXX.
*/
s = splnet();
+ SOCK_LOCK(so);
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
if (fmp->pm_server->f_count == 1) {
+ SOCK_UNLOCK(so);
error = ECONNREFUSED;
splx(s);
goto bad;
}
- (void) tsleep((caddr_t) &so->so_timeo, PSOCK, "portalcon", 5 * hz);
+ (void) msleep((caddr_t) &so->so_timeo, SOCK_MTX(so), PSOCK, "portalcon", 5 * hz);
}
+ SOCK_UNLOCK(so);
splx(s);
if (so->so_error) {
OpenPOWER on IntegriCloud