X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=client.c;h=7267333d3128017e09d67ef7af8fa23db6a26951;hp=a65cbcba9d505795f76eb72ce2ad958c87569c97;hb=f3e8440f75f98ced28cdd19ba785718e734cf7c5;hpb=89e5fad91bc33f1687cca6b1bf5aa3084c424650 diff --git a/client.c b/client.c index a65cbcba..7267333d 100644 --- a/client.c +++ b/client.c @@ -52,9 +52,10 @@ static FLIST_HEAD(eta_list); static FLIST_HEAD(arg_list); -static struct thread_stat client_ts; -static struct group_run_stats client_gs; -static int sum_stat_clients; +struct thread_stat client_ts; +struct group_run_stats client_gs; +int sum_stat_clients; + static int sum_stat_nr; #define FIO_CLIENT_HASH_BITS 7 @@ -93,8 +94,10 @@ static struct fio_client *find_client_by_fd(int fd) flist_for_each(entry, &client_hash[bucket]) { client = flist_entry(entry, struct fio_client, hash_list); - if (client->fd == fd) + if (client->fd == fd) { + client->refs++; return client; + } } return NULL; @@ -102,6 +105,11 @@ static struct fio_client *find_client_by_fd(int fd) static void remove_client(struct fio_client *client) { + assert(client->refs); + + if (--client->refs) + return; + dprint(FD_NET, "client: removed <%s>\n", client->hostname); flist_del(&client->list); @@ -123,6 +131,11 @@ static void remove_client(struct fio_client *client) sum_stat_clients--; } +static void put_client(struct fio_client *client) +{ + remove_client(client); +} + static void __fio_client_add_cmd_option(struct fio_client *client, const char *opt) { @@ -187,6 +200,7 @@ struct fio_client *fio_client_add_explicit(struct client_ops *ops, client->fd = -1; client->ops = ops; + client->refs = 1; __fio_client_add_cmd_option(client, "fio"); @@ -235,6 +249,7 @@ int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie) client->fd = -1; client->ops = ops; + client->refs = 1; __fio_client_add_cmd_option(client, "fio"); @@ -1116,6 +1131,7 @@ int fio_handle_clients(struct client_ops *ops) retval = 1; } else if (client->error) retval = 1; + put_client(client); } }