aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/streams
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-01-23 21:06:30 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-01-23 21:06:30 +0000
commitf843c385b1c577e349de9ec9a4a256aad48b1bcf (patch)
treef5ca9f92ca3bb970b6ce2cc7de90877ed9c4ae1e /sys/dev/streams
parent37bf0fc1f8ebe0d87a6d81f97a495aec8782dadf (diff)
Notes
Diffstat (limited to 'sys/dev/streams')
-rw-r--r--sys/dev/streams/streams.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/dev/streams/streams.c b/sys/dev/streams/streams.c
index b7da7eef762f..1d779f4a9f34 100644
--- a/sys/dev/streams/streams.c
+++ b/sys/dev/streams/streams.c
@@ -207,8 +207,12 @@ streamsopen(dev_t dev, int oflags, int devtype, struct proc *p)
int error;
int family;
- if (p->p_dupfd >= 0)
+ PROC_LOCK(p);
+ if (p->p_dupfd >= 0) {
+ PROC_UNLOCK(p);
return ENODEV;
+ }
+ PROC_UNLOCK(p);
switch (minor(dev)) {
case dev_udp:
@@ -271,7 +275,9 @@ streamsopen(dev_t dev, int oflags, int devtype, struct proc *p)
fp->f_type = DTYPE_SOCKET;
(void)svr4_stream_get(fp);
+ PROC_LOCK(p);
p->p_dupfd = fd;
+ PROC_UNLOCK(p);
return ENXIO;
}
@@ -318,7 +324,9 @@ svr4_ptm_alloc(p)
case ENXIO:
return error;
case 0:
+ PROC_LOCK(p);
p->p_dupfd = p->p_retval[0];
+ PROC_UNLOCK(p);
return ENXIO;
default:
if (ttynumbers[++n] == '\0') {
@@ -367,13 +375,15 @@ svr4_delete_socket(p, fp)
struct svr4_sockcache_entry *e;
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
- if (!svr4_str_initialized) {
- TAILQ_INIT(&svr4_head);
- svr4_str_initialized = 1;
+ while (svr4_str_initialized != 2) {
+ if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {
+ TAILQ_INIT(&svr4_head);
+ atomic_store_rel_int(&svr4_str_initialized, 2);
+ }
return;
}
- for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
+ TAILQ_FOREACH(e, &svr4_head, entries)
if (e->p == p && e->cookie == cookie) {
TAILQ_REMOVE(&svr4_head, e, entries);
DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n",