Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 213821
b: refs/heads/master
c: f662c07
h: refs/heads/master
i:
  213819: 5415769
v: v3
  • Loading branch information
Allan Stephens authored and David S. Miller committed Aug 18, 2010
1 parent c73e6a1 commit 1e69fa5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 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: 35997e3157eba16c6124d440bdf9272087129b2a
refs/heads/master: f662c07058f7e6365ae65080d772f9122f6f50a9
61 changes: 40 additions & 21 deletions trunk/net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,36 +429,55 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
* 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!
*
* socket state flags set
* ------------ ---------
* unconnected no read flags
* no write flags
*
* connecting POLLIN/POLLRDNORM if ACK/NACK in rx queue
* no write flags
*
* connected POLLIN/POLLRDNORM if data in rx queue
* POLLOUT if port is not congested
*
* disconnecting POLLIN/POLLRDNORM/POLLHUP
* no write flags
*
* listening POLLIN if SYN in rx queue
* no write flags
*
* ready POLLIN/POLLRDNORM if data in rx queue
* [connectionless] POLLOUT (since port cannot be congested)
*
* IMPORTANT: The fact that a read or write operation is indicated does NOT
* imply that the operation will succeed, merely that it should be performed
* and will not block.
*/

static unsigned int poll(struct file *file, struct socket *sock,
poll_table *wait)
{
struct sock *sk = sock->sk;
u32 mask;
u32 mask = 0;

poll_wait(file, sk_sleep(sk), 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;
switch ((int)sock->state) {
case SS_READY:
case SS_CONNECTED:
if (!tipc_sk_port(sk)->congested)
mask |= POLLOUT;
/* fall thru' */
case SS_CONNECTING:
case SS_LISTENING:
if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= (POLLIN | POLLRDNORM);
break;
case SS_DISCONNECTING:
mask = (POLLIN | POLLRDNORM | POLLHUP);
break;
}

return mask;
}
Expand Down

0 comments on commit 1e69fa5

Please sign in to comment.