Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90407
b: refs/heads/master
c: 9b674e8
h: refs/heads/master
i:
  90405: 33ba7cd
  90403: 5edd63c
  90399: 57a66cc
v: v3
  • Loading branch information
Allan Stephens authored and David S. Miller committed Mar 26, 2008
1 parent 9057390 commit 773458e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 67727184f28c38d06013c6659560bb046c1d9f9c
refs/heads/master: 9b674e82b73a61844967b32e1b4ecaf8eb9d1805
78 changes: 36 additions & 42 deletions trunk/net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,6 @@ static void sock_unlock(struct tipc_sock* tsock)
spin_unlock_bh(tsock->p->lock);
}

/**
* pollmask - determine the current set of poll() events for a socket
* @sock: socket structure
*
* TIPC sets the returned events as follows:
* a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty
* or if a connection-oriented socket is does not have an active connection
* (i.e. a read operation will not block).
* b) POLLOUT is set except when a socket's connection has been terminated
* (i.e. a write operation will not block).
* c) POLLHUP is set when a socket's connection has been terminated.
*
* IMPORTANT: The fact that a read or write operation will not block does NOT
* imply that the operation will succeed!
*
* Returns pollmask value
*/

static u32 pollmask(struct socket *sock)
{
u32 mask;

if ((skb_queue_len(&sock->sk->sk_receive_queue) != 0) ||
(sock->state == SS_UNCONNECTED) ||
(sock->state == SS_DISCONNECTING))
mask = (POLLRDNORM | POLLIN);
else
mask = 0;

if (sock->state == SS_DISCONNECTING)
mask |= POLLHUP;
else
mask |= POLLOUT;

return mask;
}


/**
* advance_queue - discard first buffer in queue
* @tsock: TIPC socket
Expand Down Expand Up @@ -390,15 +352,47 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
* @sock: socket for which to calculate the poll bits
* @wait: ???
*
* Returns the pollmask
* Returns pollmask value
*
* COMMENTARY:
* It appears that the usual socket locking mechanisms are not useful here
* since the pollmask info is potentially out-of-date the moment this routine
* exits. TCP and other protocols seem to rely on higher level poll routines
* to handle any preventable race conditions, so TIPC will do the same ...
*
* TIPC sets the returned events as follows:
* a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty
* or if a connection-oriented socket is does not have an active connection
* (i.e. a read operation will not block).
* b) POLLOUT is set except when a socket's connection has been terminated
* (i.e. a write operation will not block).
* c) POLLHUP is set when a socket's connection has been terminated.
*
* IMPORTANT: The fact that a read or write operation will not block does NOT
* imply that the operation will succeed!
*/

static unsigned int poll(struct file *file, struct socket *sock,
poll_table *wait)
{
poll_wait(file, sock->sk->sk_sleep, wait);
/* NEED LOCK HERE? */
return pollmask(sock);
struct sock *sk = sock->sk;
u32 mask;

poll_wait(file, sk->sk_sleep, wait);

if (!skb_queue_empty(&sk->sk_receive_queue) ||
(sock->state == SS_UNCONNECTED) ||
(sock->state == SS_DISCONNECTING))
mask = (POLLRDNORM | POLLIN);
else
mask = 0;

if (sock->state == SS_DISCONNECTING)
mask |= POLLHUP;
else
mask |= POLLOUT;

return mask;
}

/**
Expand Down

0 comments on commit 773458e

Please sign in to comment.