* lock a pipe for I/O, blocking other access */
| 612 | * lock a pipe for I/O, blocking other access |
| 613 | */ |
| 614 | static __inline int |
| 615 | pipelock(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 |
no outgoing calls
no test coverage detected