MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pipelock

Function pipelock

freebsd/kern/sys_pipe.c:614–637  ·  view source on GitHub ↗

* lock a pipe for I/O, blocking other access */

Source from the content-addressed store, hash-verified

612 * lock a pipe for I/O, blocking other access
613 */
614static __inline int
615pipelock(struct pipe *cpipe, int catch)
616{
617 int error, prio;
618
619 PIPE_LOCK_ASSERT(cpipe, MA_OWNED);
620
621 prio = PRIBIO;
622 if (catch)
623 prio |= PCATCH;
624 while (cpipe->pipe_state & PIPE_LOCKFL) {
625 KASSERT(cpipe->pipe_waiters >= 0,
626 ("%s: bad waiter count %d", __func__,
627 cpipe->pipe_waiters));
628 cpipe->pipe_waiters++;
629 error = msleep(cpipe, PIPE_MTX(cpipe),
630 prio, "pipelk", 0);
631 cpipe->pipe_waiters--;
632 if (error != 0)
633 return (error);
634 }
635 cpipe->pipe_state |= PIPE_LOCKFL;
636 return (0);
637}
638
639/*
640 * unlock a pipe I/O lock

Callers 4

pipe_readFunction · 0.85
pipe_direct_writeFunction · 0.85
pipe_writeFunction · 0.85
pipecloseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected