Messages in this thread Patch in this message | | | Date | Fri, 13 Nov 1998 16:27:04 +0100 (CET) | From | Mike Galbraith <> | Subject | Re: select()/poll() bug report [PATCH] |
| |
On Tue, 10 Nov 1998, David Mosberger wrote:
> This is a Linux kernel v2.1.xxx bug report. Linus says the bug has > been around forever and that it is unlikely to get fixed for v2.2 > unless someone sends him a patch that is "obviously correct" and > reasonably clean and fast.
Hi,
Anything wrong with doing it this way?
-Mike
--- linux/include/linux/poll.h.org Fri Nov 13 12:57:40 1998 +++ linux/include/linux/poll.h Fri Nov 13 15:46:06 1998 @@ -21,15 +21,13 @@ struct poll_table_entry * entry; } poll_table; -#define __MAX_POLL_TABLE_ENTRIES (PAGE_SIZE / sizeof (struct poll_table_entry)) - extern inline void poll_wait(struct file * filp, struct wait_queue ** wait_address, poll_table *p) { struct poll_table_entry * entry; if (!p || !wait_address) return; - if (p->nr >= __MAX_POLL_TABLE_ENTRIES) + if (p->nr >= __FD_SETSIZE) return; entry = p->entry + p->nr; entry->filp = filp; --- linux/fs/select.c.org Fri Nov 13 12:41:15 1998 +++ linux/fs/select.c Fri Nov 13 15:48:55 1998 @@ -127,12 +127,15 @@ int do_select(int n, fd_set_buffer *fds, long *timeout) { poll_table wait_table, *wait; - int retval, i; + int retval, i, size; long __timeout = *timeout; wait = NULL; if (__timeout) { - struct poll_table_entry *entry = (struct poll_table_entry *) __get_free_page(GFP_KERNEL); + struct poll_table_entry *entry = + (size = n * sizeof(struct poll_table_entry)) <= PAGE_SIZE ? + (struct poll_table_entry *) __get_free_page(GFP_KERNEL) + : (struct poll_table_entry *) kmalloc(size,GFP_KERNEL); if (!entry) return -ENOMEM; @@ -196,7 +199,9 @@ out: if (*timeout) { free_wait(&wait_table); - free_page((unsigned long) wait_table.entry); + size <= PAGE_SIZE ? + free_page((unsigned long) wait_table.entry) + : kfree(wait_table.entry); } /*
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |