Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48554
b: refs/heads/master
c: 838e56a
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Feb 16, 2007
1 parent 9f4af3f commit 4b5db29
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 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: beb497ab48b1639282129f7bc18fef311fffff3d
refs/heads/master: 838e56a11cdb2abaf490eb7879ab021db938d47d
38 changes: 20 additions & 18 deletions trunk/arch/um/os-Linux/sigio.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,22 @@ static int write_sigio_thread(void *unused)

static int need_poll(struct pollfds *polls, int n)
{
if(n <= polls->size){
polls->used = n;
struct pollfd *new;

if(n <= polls->size)
return 0;
}
kfree(polls->poll);
polls->poll = um_kmalloc_atomic(n * sizeof(struct pollfd));
if(polls->poll == NULL){

new = um_kmalloc_atomic(n * sizeof(struct pollfd));
if(new == NULL){
printk("need_poll : failed to allocate new pollfds\n");
polls->size = 0;
polls->used = 0;
return -ENOMEM;
}

memcpy(new, polls->poll, polls->used * sizeof(struct pollfd));
kfree(polls->poll);

polls->poll = new;
polls->size = n;
polls->used = n;
return 0;
}

Expand Down Expand Up @@ -171,15 +173,15 @@ int add_sigio_fd(int fd)
goto out;
}

n = current_poll.used + 1;
err = need_poll(&next_poll, n);
n = current_poll.used;
err = need_poll(&next_poll, n + 1);
if(err)
goto out;

for(i = 0; i < current_poll.used; i++)
next_poll.poll[i] = current_poll.poll[i];

next_poll.poll[n - 1] = *p;
memcpy(next_poll.poll, current_poll.poll,
current_poll.used * sizeof(struct pollfd));
next_poll.poll[n] = *p;
next_poll.used = n + 1;
update_thread();
out:
sigio_unlock();
Expand Down Expand Up @@ -214,6 +216,7 @@ int ignore_sigio_fd(int fd)
if(p->fd != fd)
next_poll.poll[n++] = *p;
}
next_poll.used = current_poll.used - 1;

update_thread();
out:
Expand Down Expand Up @@ -331,10 +334,9 @@ void maybe_sigio_broken(int fd, int read)

sigio_lock();
err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1);
if(err){
printk("maybe_sigio_broken - failed to add pollfd\n");
if(err)
goto out;
}

all_sigio_fds.poll[all_sigio_fds.used++] =
((struct pollfd) { .fd = fd,
.events = read ? POLLIN : POLLOUT,
Expand Down

0 comments on commit 4b5db29

Please sign in to comment.