From 213e01e606bc0434059fced84b2bcf349e622bcc Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Tue, 17 Jan 2006 13:13:14 +0100 Subject: [PATCH] server: Make sure to release the fd we grabbed in all cases. --- server/fd.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/server/fd.c b/server/fd.c index 90fb7af20d1..37e0ef214da 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1505,16 +1505,23 @@ int default_fd_signaled( struct object *obj, struct thread *thread ) int events, ret; struct fd *fd = get_obj_fd( obj ); - if (fd->inode) return 1; /* regular files are always signaled */ - - events = fd->fd_ops->get_poll_events( fd ); - ret = check_fd_events( fd, events ) != 0; - - if (ret) - set_fd_events( fd, 0 ); /* stop waiting on select() if we are signaled */ - else if (!list_empty( &obj->wait_queue )) - set_fd_events( fd, events ); /* restart waiting on poll() if we are no longer signaled */ + if (fd->inode) ret = 1; /* regular files are always signaled */ + else + { + events = fd->fd_ops->get_poll_events( fd ); + ret = check_fd_events( fd, events ) != 0; + if (ret) + { + /* stop waiting on select() if we are signaled */ + set_fd_events( fd, 0 ); + } + else if (!list_empty( &obj->wait_queue )) + { + /* restart waiting on poll() if we are no longer signaled */ + set_fd_events( fd, events ); + } + } release_object( fd ); return ret; }