From 3a5dfe8ada4ac1b9a3f0876dc31c64e9236dc77d Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 1 Jul 1995 21:15:49 +0000 Subject: Initial revision --- pflocal/sock.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pflocal/sock.c (limited to 'pflocal') 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; +} -- cgit v1.2.3