Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29037
b: refs/heads/master
c: 4a4b69f
h: refs/heads/master
i:
  29035: 6288801
v: v3
  • Loading branch information
Vadim Lobanov authored and Linus Torvalds committed Jun 23, 2006
1 parent b54d30e commit 76680ff
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 33 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: 2da132646358c853d5caf296d079aefc69358d46
refs/heads/master: 4a4b69f79ba7286794765a856349e380f984a6cb
83 changes: 51 additions & 32 deletions trunk/fs/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,37 +546,38 @@ struct poll_list {

#define POLLFD_PER_PAGE ((PAGE_SIZE-sizeof(struct poll_list)) / sizeof(struct pollfd))

static void do_pollfd(unsigned int num, struct pollfd * fdpage,
poll_table ** pwait, int *count)
/*
* Fish for pollable events on the pollfd->fd file descriptor. We're only
* interested in events matching the pollfd->events mask, and the result
* matching that mask is both recorded in pollfd->revents and returned. The
* pwait poll_table will be used by the fd-provided poll handler for waiting,
* if non-NULL.
*/
static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
{
int i;

for (i = 0; i < num; i++) {
int fd;
unsigned int mask;
struct pollfd *fdp;

mask = 0;
fdp = fdpage+i;
fd = fdp->fd;
if (fd >= 0) {
int fput_needed;
struct file * file = fget_light(fd, &fput_needed);
mask = POLLNVAL;
if (file != NULL) {
mask = DEFAULT_POLLMASK;
if (file->f_op && file->f_op->poll)
mask = file->f_op->poll(file, *pwait);
mask &= fdp->events | POLLERR | POLLHUP;
fput_light(file, fput_needed);
}
if (mask) {
*pwait = NULL;
(*count)++;
}
unsigned int mask;
int fd;

mask = 0;
fd = pollfd->fd;
if (fd >= 0) {
int fput_needed;
struct file * file;

file = fget_light(fd, &fput_needed);
mask = POLLNVAL;
if (file != NULL) {
mask = DEFAULT_POLLMASK;
if (file->f_op && file->f_op->poll)
mask = file->f_op->poll(file, pwait);
/* Mask out unneeded events. */
mask &= pollfd->events | POLLERR | POLLHUP;
fput_light(file, fput_needed);
}
fdp->revents = mask;
}
pollfd->revents = mask;

return mask;
}

static int do_poll(unsigned int nfds, struct poll_list *list,
Expand All @@ -594,11 +595,29 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
long __timeout;

set_current_state(TASK_INTERRUPTIBLE);
walk = list;
while(walk != NULL) {
do_pollfd( walk->len, walk->entries, &pt, &count);
walk = walk->next;
for (walk = list; walk != NULL; walk = walk->next) {
struct pollfd * pfd, * pfd_end;

pfd = walk->entries;
pfd_end = pfd + walk->len;
for (; pfd != pfd_end; pfd++) {
/*
* Fish for events. If we found one, record it
* and kill the poll_table, so we don't
* needlessly register any other waiters after
* this. They'll get immediately deregistered
* when we break out and return.
*/
if (do_pollfd(pfd, pt)) {
count++;
pt = NULL;
}
}
}
/*
* All waiters have already been registered, so don't provide
* a poll_table to them on the next loop iteration.
*/
pt = NULL;
if (count || !*timeout || signal_pending(current))
break;
Expand Down

0 comments on commit 76680ff

Please sign in to comment.