Commit e19690cd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] epoll timeout and syscall return types

Patch from Davide Libenzi <davidel@xmailserver.org>

Changes :
 - Timeout overflow check
 - Ceil()ing of ms->jif conversion
 - Syscalls return type int->long
parent 2b8a659c
...@@ -261,7 +261,7 @@ static int ep_send_events(struct eventpoll *ep, struct epitem **aepi, int nepi, ...@@ -261,7 +261,7 @@ static int ep_send_events(struct eventpoll *ep, struct epitem **aepi, int nepi,
struct epoll_event *events); struct epoll_event *events);
static int ep_events_transfer(struct eventpoll *ep, struct epoll_event *events, int maxevents); 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, 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 int eventpollfs_delete_dentry(struct dentry *dentry);
static struct inode *ep_eventpoll_inode(void); static struct inode *ep_eventpoll_inode(void);
static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type, static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
...@@ -446,7 +446,7 @@ void eventpoll_release(struct file *file) ...@@ -446,7 +446,7 @@ void eventpoll_release(struct file *file)
* file descriptors inside the epoll interface. It is the kernel part of * file descriptors inside the epoll interface. It is the kernel part of
* the userspace epoll_create(2). * the userspace epoll_create(2).
*/ */
asmlinkage int sys_epoll_create(int size) asmlinkage long sys_epoll_create(int size)
{ {
int error, fd; int error, fd;
unsigned int hashbits; unsigned int hashbits;
...@@ -492,7 +492,7 @@ asmlinkage int sys_epoll_create(int size) ...@@ -492,7 +492,7 @@ asmlinkage int sys_epoll_create(int size)
* file that enable the insertion/removal/change of file descriptors inside * 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). * 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; int error;
struct file *file, *tfile; struct file *file, *tfile;
...@@ -596,8 +596,8 @@ asmlinkage int sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event ...@@ -596,8 +596,8 @@ asmlinkage int sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event
* Implement the event wait interface for the eventpoll file. It is the kernel * Implement the event wait interface for the eventpoll file. It is the kernel
* part of the user space epoll_wait(2). * part of the user space epoll_wait(2).
*/ */
asmlinkage int sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, asmlinkage long sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout) int timeout)
{ {
int error; int error;
struct file *file; struct file *file;
...@@ -1420,7 +1420,7 @@ static int ep_events_transfer(struct eventpoll *ep, struct epoll_event *events, ...@@ -1420,7 +1420,7 @@ static int ep_events_transfer(struct eventpoll *ep, struct epoll_event *events,
static int ep_poll(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)
{ {
int res, eavail; int res, eavail;
unsigned long flags; unsigned long flags;
...@@ -1428,10 +1428,12 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event *events, int maxeven ...@@ -1428,10 +1428,12 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event *events, int maxeven
wait_queue_t wait; wait_queue_t wait;
/* /*
* Calculate the timeout by checking for the "infinite" value ( -1 ). * Calculate the timeout by checking for the "infinite" value ( -1 )
* The passed timeout is in milliseconds, that why (t * HZ) / 1000. * 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: retry:
write_lock_irqsave(&ep->lock, flags); write_lock_irqsave(&ep->lock, flags);
......
...@@ -32,10 +32,10 @@ struct file; ...@@ -32,10 +32,10 @@ struct file;
/* Kernel space functions implementing the user space "epoll" API */ /* Kernel space functions implementing the user space "epoll" API */
asmlinkage int sys_epoll_create(int size); asmlinkage long sys_epoll_create(int size);
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);
asmlinkage int sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents, asmlinkage long sys_epoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout); int timeout);
/* Used to initialize the epoll bits inside the "struct file" */ /* Used to initialize the epoll bits inside the "struct file" */
void eventpoll_init_file(struct file *file); void eventpoll_init_file(struct file *file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment