+struct fio_client {
+ struct flist_head list;
+ struct sockaddr_in addr;
+ char *hostname;
+ int fd;
+};
+
+static FLIST_HEAD(client_list);
+static unsigned int nr_clients;
+
+static struct fio_client *find_client_by_fd(int fd)
+{
+ struct fio_client *client;
+ struct flist_head *entry;
+
+ flist_for_each(entry, &client_list) {
+ client = flist_entry(entry, struct fio_client, list);
+
+ if (client->fd == fd)
+ return client;
+ }
+
+ return NULL;
+}
+
+static struct fio_client *find_client_by_name(const char *name)
+{
+ struct fio_client *client;
+ struct flist_head *entry;
+
+ flist_for_each(entry, &client_list) {
+ client = flist_entry(entry, struct fio_client, list);
+
+ if (!strcmp(name, client->hostname))
+ return client;
+ }
+
+ return NULL;
+}
+
+static void remove_client(struct fio_client *client)
+{
+ printf("remove client %s\n", client->hostname);
+ flist_del(&client->list);
+ nr_clients--;
+ free(client->hostname);
+ free(client);
+}