#include "flist.h"
#include "hash.h"
+struct client_eta {
+ struct jobs_eta eta;
+ unsigned int pending;
+};
+
struct fio_client {
struct flist_head list;
struct flist_head hash_list;
int skip_newline;
int is_sock;
- int waiting_eta;
+
+ struct flist_head eta_list;
+ struct client_eta *eta_in_flight;
uint16_t argc;
char **argv;
Client_exited = 4,
};
-struct client_eta {
- struct jobs_eta eta;
- unsigned int pending;
-};
-
static FLIST_HEAD(client_list);
+static FLIST_HEAD(eta_list);
#define FIO_CLIENT_HASH_BITS 7
#define FIO_CLIENT_HASH_SZ (1 << FIO_CLIENT_HASH_BITS)
static struct flist_head client_hash[FIO_CLIENT_HASH_SZ];
static int handle_client(struct fio_client *client);
+static void dec_jobs_eta(struct client_eta *eta);
static void fio_client_add_hash(struct fio_client *client)
{
fio_client_remove_hash(client);
- /* FIXME: check ->waiting_eta and handle it */
+ if (!flist_empty(&client->eta_list)) {
+ flist_del_init(&client->eta_list);
+ dec_jobs_eta(client->eta_in_flight);
+ }
free(client->hostname);
if (client->argv)
INIT_FLIST_HEAD(&client->list);
INIT_FLIST_HEAD(&client->hash_list);
+ INIT_FLIST_HEAD(&client->eta_list);
if (fio_server_parse_string(hostname, &client->hostname,
&client->is_sock, &client->port,
dst->eta_sec = je->eta_sec;
}
-static void handle_eta(struct fio_net_cmd *cmd)
+static void dec_jobs_eta(struct client_eta *eta)
+{
+ if (!--eta->pending) {
+ display_thread_status(&eta->eta);
+ free(eta);
+ }
+}
+
+static void handle_eta(struct fio_client *client, struct fio_net_cmd *cmd)
{
struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
struct client_eta *eta = (struct client_eta *) cmd->tag;
dprint(FD_NET, "client: got eta tag %p, %d\n", eta, eta->pending);
+ flist_del_init(&client->eta_list);
+
convert_jobs_eta(je);
sum_jobs_eta(&eta->eta, je);
-
- if (!--eta->pending) {
- display_thread_status(&eta->eta);
- free(eta);
- }
+ dec_jobs_eta(eta);
}
static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
free(cmd);
break;
case FIO_NET_CMD_ETA:
- handle_eta(cmd);
+ handle_eta(client, cmd);
free(cmd);
break;
case FIO_NET_CMD_PROBE:
struct fio_client *client;
struct flist_head *entry;
struct client_eta *eta;
+ int skipped = 0;
dprint(FD_NET, "client: request eta (%d)\n", nr_clients);
- /*
- * We need to do something more clever about checking status
- * of command being send, client haven't sent previous ETA
- * already, etc.
- */
-
eta = malloc(sizeof(*eta));
memset(&eta->eta, 0, sizeof(eta->eta));
eta->pending = nr_clients;
flist_for_each(entry, &client_list) {
client = flist_entry(entry, struct fio_client, list);
- client->waiting_eta = 1;
+ if (!flist_empty(&client->eta_list)) {
+ skipped++;
+ continue;
+ }
+
+ flist_add_tail(&client->eta_list, &eta_list);
fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_SEND_ETA,
(uint64_t) eta);
}
+ while (skipped--)
+ dec_jobs_eta(eta);
+
dprint(FD_NET, "client: requested eta tag %p\n", eta);
}