Page MenuHomeFreeBSD

D27273.id79765.diff
No OneTemporary

D27273.id79765.diff

Index: sys/kern/sys_pipe.c
===================================================================
--- sys/kern/sys_pipe.c
+++ sys/kern/sys_pipe.c
@@ -622,9 +622,13 @@
if (catch)
prio |= PCATCH;
while (cpipe->pipe_state & PIPE_LOCKFL) {
- cpipe->pipe_state |= PIPE_LWANT;
+ KASSERT(cpipe->pipe_waiters >= 0,
+ ("%s: bad waiter count %d", __func__,
+ cpipe->pipe_waiters));
+ cpipe->pipe_waiters++;
error = msleep(cpipe, PIPE_MTX(cpipe),
prio, "pipelk", 0);
+ cpipe->pipe_waiters--;
if (error != 0)
return (error);
}
@@ -642,10 +646,12 @@
PIPE_LOCK_ASSERT(cpipe, MA_OWNED);
KASSERT(cpipe->pipe_state & PIPE_LOCKFL,
("Unlocked pipe passed to pipeunlock"));
+ KASSERT(cpipe->pipe_waiters >= 0,
+ ("%s: bad waiter count %d", __func__,
+ cpipe->pipe_waiters));
cpipe->pipe_state &= ~PIPE_LOCKFL;
- if (cpipe->pipe_state & PIPE_LWANT) {
- cpipe->pipe_state &= ~PIPE_LWANT;
- wakeup(cpipe);
+ if (cpipe->pipe_waiters > 0) {
+ wakeup_one(cpipe);
}
}
Index: sys/sys/pipe.h
===================================================================
--- sys/sys/pipe.h
+++ sys/sys/pipe.h
@@ -116,9 +116,10 @@
struct pipe *pipe_peer; /* link with other direction */
struct pipepair *pipe_pair; /* container structure pointer */
u_short pipe_state; /* pipe status info */
- u_short pipe_type; /* pipe type info */
+ u_char pipe_type; /* pipe type info */
+ u_char pipe_present; /* still present? */
+ int pipe_waiters; /* pipelock waiters */
int pipe_busy; /* busy flag, mostly to handle rundown sanely */
- int pipe_present; /* still present? */
int pipe_wgen; /* writer generation for named pipe */
ino_t pipe_ino; /* fake inode for stat(2) */
};

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 19, 8:39 AM (13 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29956868
Default Alt Text
D27273.id79765.diff (1 KB)

Event Timeline