summaryrefslogtreecommitdiff
path: root/pflocal/sock.c
blob: 21fce3acd387ed9838d04b8d074d2b67e9f51265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}