client: re-setup poll fd array in case a client disappears
authorJens Axboe <axboe@kernel.dk>
Sat, 1 Oct 2011 18:40:32 +0000 (12:40 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 1 Oct 2011 18:40:32 +0000 (12:40 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c

index 054043d4eb423f913009644434c062fe77b0959b..c080c17d03fadaf36466398bb7c062c0bb15b5d0 100644 (file)
--- a/client.c
+++ b/client.c
@@ -61,7 +61,6 @@ static struct fio_client *find_client_by_name(const char *name)
 
 static void remove_client(struct fio_client *client)
 {
-       printf("remove client %s\n", client->hostname);
        flist_del(&client->list);
        nr_clients--;
        free(client->hostname);
@@ -231,19 +230,22 @@ int fio_handle_clients(void)
        struct fio_client *client;
        struct flist_head *entry;
        struct pollfd *pfds;
-       int i = 0, ret = 0;
+       int i, ret = 0;
 
        pfds = malloc(nr_clients * sizeof(struct pollfd));
 
-       flist_for_each(entry, &client_list) {
-               client = flist_entry(entry, struct fio_client, list);
+       while (!exit_backend && nr_clients) {
+               i = 0;
+               flist_for_each(entry, &client_list) {
+                       client = flist_entry(entry, struct fio_client, list);
 
-               pfds[i].fd = client->fd;
-               pfds[i].events = POLLIN;
-               i++;
-       }
+                       pfds[i].fd = client->fd;
+                       pfds[i].events = POLLIN;
+                       i++;
+               }
+
+               assert(i == nr_clients);
 
-       while (!exit_backend && nr_clients) {
                ret = poll(pfds, nr_clients, 100);
                if (ret < 0) {
                        if (errno == EINTR)