diff options
author | jeff <jeff@FreeBSD.org> | 2007-12-30 01:42:15 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2007-12-30 01:42:15 +0000 |
commit | ce1863880500c459eb1395c1d6f81819e02e6608 (patch) | |
tree | 0f2354bfc200294c2629e6ecfba76e364beda579 /sys/kern/kern_event.c | |
parent | bedce823534f9510ef9c65764069f927d359aeb8 (diff) | |
download | FreeBSD-src-ce1863880500c459eb1395c1d6f81819e02e6608.zip FreeBSD-src-ce1863880500c459eb1395c1d6f81819e02e6608.tar.gz |
Remove explicit locking of struct file.
- Introduce a finit() which is used to initailize the fields of struct file
in such a way that the ops vector is only valid after the data, type,
and flags are valid.
- Protect f_flag and f_count with atomic operations.
- Remove the global list of all files and associated accounting.
- Rewrite the unp garbage collection such that it no longer requires
the global list of all files and instead uses a list of all unp sockets.
- Mark sockets in the accept queue so we don't incorrectly gc them.
Tested by: kris, pho
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r-- | sys/kern/kern_event.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 4d75822..b5d01d0 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -531,12 +531,7 @@ kqueue(struct thread *td, struct kqueue_args *uap) SLIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); FILEDESC_XUNLOCK(fdp); - FILE_LOCK(fp); - fp->f_flag = FREAD | FWRITE; - fp->f_type = DTYPE_KQUEUE; - fp->f_data = kq; - fp->f_ops = &kqueueops; - FILE_UNLOCK(fp); + finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops); fdrop(fp, td); td->td_retval[0] = fd; @@ -990,24 +985,17 @@ kqueue_acquire(struct file *fp, struct kqueue **kqp) error = 0; - FILE_LOCK(fp); - do { - kq = fp->f_data; - if (fp->f_type != DTYPE_KQUEUE || kq == NULL) { - error = EBADF; - break; - } - *kqp = kq; - KQ_LOCK(kq); - if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { - KQ_UNLOCK(kq); - error = EBADF; - break; - } - kq->kq_refcnt++; + kq = fp->f_data; + if (fp->f_type != DTYPE_KQUEUE || kq == NULL) + return (EBADF); + *kqp = kq; + KQ_LOCK(kq); + if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { KQ_UNLOCK(kq); - } while (0); - FILE_UNLOCK(fp); + return (EBADF); + } + kq->kq_refcnt++; + KQ_UNLOCK(kq); return error; } |