char *hostname;
int port;
int fd;
+ unsigned int refs;
char *name;
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;
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);
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)
{
return -1;
client->fd = -1;
+ client->refs = 1;
__fio_client_add_cmd_option(client, "fio");
retval = 1;
} else if (client->error)
retval = 1;
+ put_client(client);
}
}