Received: from mnm [127.0.0.1] by localhost with POP3 (fetchmail-5.9.0) for akpm@localhost (single-drop); Fri, 24 Jan 2003 19:21:31 -0800 (PST) Received: from digeo-e2k04.digeo.com ([192.168.2.24]) by pao-ex01.pao.digeo.com with Microsoft SMTPSVC(5.0.2195.4905); Fri, 24 Jan 2003 19:15:58 -0800 Received: from digeo-nav01.digeo.com ([192.168.1.233]) by digeo-e2k04.digeo.com with Microsoft SMTPSVC(5.0.2195.5329); Fri, 24 Jan 2003 19:15:58 -0800 Received: from packet.digeo.com ([192.168.17.15]) by digeo-nav01.digeo.com (NAVGW 2.5.2.12) with SMTP id M2003012419190909420 for ; Fri, 24 Jan 2003 19:19:09 -0800 Received: from x35.xmailserver.org (x35.xmailserver.org [208.129.208.51]) by packet.digeo.com (8.9.3+Sun/8.9.3) with ESMTP id TAA14677 for ; Fri, 24 Jan 2003 19:15:57 -0800 (PST) X-AuthUser: davidel@xmailserver.org Received: from blue1.dev.mcafeelabs.com (161.69.79.199) by xmailserver.org with [XMail 1.12 (Linux/Ix86) ESMTP Server] id for from ; Fri, 24 Jan 2003 19:27:49 -0800 Date: Fri, 24 Jan 2003 19:21:03 -0800 (PST) From: Davide Libenzi X-X-Sender: davide@blue1.dev.mcafeelabs.com To: Linux Kernel Mailing List cc: Andrew Morton , Linus Torvalds Subject: [patch] epoll timeout and syscall return types ... Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-Path: davidel@xmailserver.org X-OriginalArrivalTime: 25 Jan 2003 03:15:58.0267 (UTC) FILETIME=[148E68B0:01C2C420] X-Spam-Status: No, hits=-5.0 required=6.0 tests=UNIFIED_PATCH version=2.31 X-Spam-Level: Changes : *) Timeout overflow check *) Ceil()ing of ms->jif conversion *) Syscalls return type int->long PS: Andrew, I'm CCing you because I seem to remember that Linus is in vacation mode. - Davide fs/eventpoll.c | 20 +++++++++++--------- include/linux/eventpoll.h | 8 ++++---- 2 files changed, 15 insertions, 13 deletions diff -Nru linux-2.5.59.vanilla/fs/eventpoll.c linux-2.5.59.epoll/fs/eventpoll.c --- linux-2.5.59.vanilla/fs/eventpoll.c Thu Jan 16 18:22:02 2003 +++ linux-2.5.59.epoll/fs/eventpoll.c Fri Jan 24 19:18:51 2003 @@ -261,7 +261,7 @@ struct epoll_event *events); static int ep_events_transfer(struct eventpoll *ep, struct epoll_event *events, int maxevents); static int ep_poll(struct eventpoll *ep, struct epoll_event *events, int maxevents, - int timeout); + long timeout); static int eventpollfs_delete_dentry(struct dentry *dentry); static struct inode *ep_eventpoll_inode(void); static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type, @@ -446,7 +446,7 @@ * file descriptors inside the epoll interface. It is the kernel part of * the userspace epoll_create(2). */ -asmlinkage int sys_epoll_create(int size) +asmlinkage long sys_epoll_create(int size) { int error, fd; unsigned int hashbits; @@ -492,7 +492,7 @@ * file that enable the insertion/removal/change of file descriptors inside * the interest set. It rapresents the kernel part of the user spcae epoll_ctl(2). */ -asmlinkage int sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) +asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) { int error; struct file *file, *tfile; @@ -596,8 +596,8 @@ * Implement the event wait interface for the eventpoll file. It is the kernel * part of the user space epoll_wait(2). */ -asmlinkage int sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, - int timeout) +asmlinkage long sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, + int timeout) { int error; struct file *file; @@ -1420,7 +1420,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event *events, int maxevents, - int timeout) + long timeout) { int res, eavail; unsigned long flags; @@ -1428,10 +1428,12 @@ wait_queue_t wait; /* - * Calculate the timeout by checking for the "infinite" value ( -1 ). - * The passed timeout is in milliseconds, that why (t * HZ) / 1000. + * Calculate the timeout by checking for the "infinite" value ( -1 ) + * and the overflow condition. The passed timeout is in milliseconds, + * that why (t * HZ) / 1000. */ - jtimeout = timeout == -1 ? MAX_SCHEDULE_TIMEOUT: (timeout * HZ) / 1000; + jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? + MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; retry: write_lock_irqsave(&ep->lock, flags); diff -Nru linux-2.5.59.vanilla/include/linux/eventpoll.h linux-2.5.59.epoll/include/linux/eventpoll.h --- linux-2.5.59.vanilla/include/linux/eventpoll.h Thu Jan 16 18:22:05 2003 +++ linux-2.5.59.epoll/include/linux/eventpoll.h Fri Jan 24 18:51:37 2003 @@ -32,10 +32,10 @@ /* Kernel space functions implementing the user space "epoll" API */ -asmlinkage int sys_epoll_create(int size); -asmlinkage int sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); -asmlinkage int sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, - int timeout); +asmlinkage long sys_epoll_create(int size); +asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +asmlinkage long sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, + int timeout); /* Used to initialize the epoll bits inside the "struct file" */ void eventpoll_init_file(struct file *file);