diff options
-rw-r--r-- | pflocal/sock.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pflocal/sock.c b/pflocal/sock.c new file mode 100644 index 00000000..21fce3ac --- /dev/null +++ b/pflocal/sock.c @@ -0,0 +1,32 @@ + +/* Returns the pipe that SOCKET is reading from, locked and with an + additional reference, or NULL if it has none. SOCKET mustn't be locked. */ +struct pipe * +socket_aquire_read_pipe (struct socket *socket) +{ + struct pipe *pipe; + + mutex_lock (&socket->lock); + pipe = user->socket->read_pipe; + if (pipe != NULL) + pipe_aquire (pipe); /* Do this before unlocking the socket! */ + mutex_unlock (&socket->lock); + + return pipe; +} + +/* Returns the pipe that SOCKET is writing from, locked and with an + additional reference, or NULL if it has none. SOCKET mustn't be locked. */ +struct pipe * +socket_aquire_write_pipe (struct socket *socket) +{ + struct pipe *pipe; + + mutex_lock (&socket->lock); + pipe = user->socket->write_pipe; + if (pipe != NULL) + pipe_aquire (pipe); /* Do this before unlocking the socket! */ + mutex_unlock (&socket->lock); + + return pipe; +} |