From 8a22e151be14f3eccf98b04a15dc21c4059ef326 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 13 Sep 2005 10:39:24 +0000 Subject: [PATCH] As a result of kqueue locking work, socket buffer locks will always be held when entering a kqueue filter for fifos via a socket buffer event: as such, assert the lock unconditionally rather than acquiring it conditionall. MFC after: 3 days --- sys/fs/fifofs/fifo_vnops.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index f0dfd0078a85..fddcabb6509c 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -393,22 +393,16 @@ static int filt_fiforead(struct knote *kn, long hint) { struct socket *so = (struct socket *)kn->kn_hook; - int need_lock, result; - need_lock = !SOCKBUF_OWNED(&so->so_rcv); - if (need_lock) - SOCKBUF_LOCK(&so->so_rcv); + SOCKBUF_LOCK_ASSERT(&so->so_rcv); kn->kn_data = so->so_rcv.sb_cc; if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; - result = 1; + return (1); } else { kn->kn_flags &= ~EV_EOF; - result = (kn->kn_data > 0); + return (kn->kn_data > 0); } - if (need_lock) - SOCKBUF_UNLOCK(&so->so_rcv); - return (result); } static void @@ -427,22 +421,16 @@ static int filt_fifowrite(struct knote *kn, long hint) { struct socket *so = (struct socket *)kn->kn_hook; - int need_lock, result; - need_lock = !SOCKBUF_OWNED(&so->so_snd); - if (need_lock) - SOCKBUF_LOCK(&so->so_snd); + SOCKBUF_LOCK_ASSERT(&so->so_snd); kn->kn_data = sbspace(&so->so_snd); if (so->so_snd.sb_state & SBS_CANTSENDMORE) { kn->kn_flags |= EV_EOF; - result = 1; + return (1); } else { kn->kn_flags &= ~EV_EOF; - result = (kn->kn_data >= so->so_snd.sb_lowat); + return (kn->kn_data >= so->so_snd.sb_lowat); } - if (need_lock) - SOCKBUF_UNLOCK(&so->so_snd); - return (result); } static void