|
@@ -97,20 +97,22 @@ static int write_sigio_thread(void *unused)
|
|
|
|
|
|
static int need_poll(struct pollfds *polls, int n)
|
|
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;
|
|
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");
|
|
printk("need_poll : failed to allocate new pollfds\n");
|
|
- polls->size = 0;
|
|
|
|
- polls->used = 0;
|
|
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ memcpy(new, polls->poll, polls->used * sizeof(struct pollfd));
|
|
|
|
+ kfree(polls->poll);
|
|
|
|
+
|
|
|
|
+ polls->poll = new;
|
|
polls->size = n;
|
|
polls->size = n;
|
|
- polls->used = n;
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -171,15 +173,15 @@ int add_sigio_fd(int fd)
|
|
goto out;
|
|
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)
|
|
if(err)
|
|
goto out;
|
|
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();
|
|
update_thread();
|
|
out:
|
|
out:
|
|
sigio_unlock();
|
|
sigio_unlock();
|
|
@@ -214,6 +216,7 @@ int ignore_sigio_fd(int fd)
|
|
if(p->fd != fd)
|
|
if(p->fd != fd)
|
|
next_poll.poll[n++] = *p;
|
|
next_poll.poll[n++] = *p;
|
|
}
|
|
}
|
|
|
|
+ next_poll.used = current_poll.used - 1;
|
|
|
|
|
|
update_thread();
|
|
update_thread();
|
|
out:
|
|
out:
|
|
@@ -331,10 +334,9 @@ void maybe_sigio_broken(int fd, int read)
|
|
|
|
|
|
sigio_lock();
|
|
sigio_lock();
|
|
err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1);
|
|
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;
|
|
goto out;
|
|
- }
|
|
|
|
|
|
+
|
|
all_sigio_fds.poll[all_sigio_fds.used++] =
|
|
all_sigio_fds.poll[all_sigio_fds.used++] =
|
|
((struct pollfd) { .fd = fd,
|
|
((struct pollfd) { .fd = fd,
|
|
.events = read ? POLLIN : POLLOUT,
|
|
.events = read ? POLLIN : POLLOUT,
|