diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-02 20:55:41 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-02 20:55:41 +0100 |
commit | 56465eb694ba2077de37e66600c7bef96061cbe4 (patch) | |
tree | 2799fe8d1186645c659d1c138485ed796bc2604c /src/guestfs.c | |
parent | 163e399a001a300a53a4c99887742608d23e09ad (diff) | |
download | libguestfs-56465eb694ba2077de37e66600c7bef96061cbe4.tar.gz libguestfs-56465eb694ba2077de37e66600c7bef96061cbe4.tar.xz libguestfs-56465eb694ba2077de37e66600c7bef96061cbe4.zip |
Correctly handle the case when select runs out of filehandles.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r-- | src/guestfs.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/guestfs.c b/src/guestfs.c index 7e883035..ea86f1ba 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -899,6 +899,7 @@ static fd_set wset; static fd_set xset; static int select_init_done = 0; static int max_fd = -1; +static int nr_fds = 0; static struct handle_cb_data *handle_cb_data = NULL; static void @@ -962,6 +963,8 @@ select_add_handle (guestfs_h *g, int fd, int events, handle_cb_data[fd].cb = cb; handle_cb_data[fd].data = data; + nr_fds++; + /* Any integer >= 0 can be the handle, and this is as good as any ... */ return fd; } @@ -991,6 +994,8 @@ select_remove_handle (guestfs_h *g, int fd) sizeof (struct handle_cb_data) * (max_fd+1)); } + nr_fds--; + return 0; } @@ -1024,6 +1029,11 @@ select_main_loop_run (guestfs_h *g) old_level = level++; while (level > old_level) { + if (nr_fds == 0) { + level = old_level; + break; + } + rset2 = rset; wset2 = wset; xset2 = xset; |