static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd);
static void handle_text(struct fio_client *client, struct fio_net_cmd *cmd);
static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd);
+static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd);
struct client_ops fio_client_ops = {
.text_op = handle_text,
.thread_status = handle_ts,
.group_stats = handle_gs,
.stop = handle_stop,
+ .start = handle_start,
.eta = display_thread_status,
.probe = handle_probe,
+ .eta_msec = FIO_CLIENT_DEF_ETA_MSEC,
};
static struct timeval eta_tv;
return NULL;
}
-static void remove_client(struct fio_client *client)
+void fio_put_client(struct fio_client *client)
{
- assert(client->refs);
-
if (--client->refs)
return;
+ free(client->hostname);
+ if (client->argv)
+ free(client->argv);
+ if (client->name)
+ free(client->name);
+
+ free(client);
+}
+
+static void remove_client(struct fio_client *client)
+{
+ assert(client->refs);
+
dprint(FD_NET, "client: removed <%s>\n", client->hostname);
- flist_del(&client->list);
+
+ if (!flist_empty(&client->list))
+ flist_del_init(&client->list);
fio_client_remove_hash(client);
fio_client_dec_jobs_eta(client->eta_in_flight, client->ops->eta);
}
- free(client->hostname);
- if (client->argv)
- free(client->argv);
- if (client->name)
- free(client->name);
-
- free(client);
nr_clients--;
sum_stat_clients--;
-}
-void fio_put_client(struct fio_client *client)
-{
- remove_client(client);
+ fio_put_client(client);
}
struct fio_client *fio_get_client(struct fio_client *client)
return 0;
}
+static void probe_client(struct fio_client *client)
+{
+ dprint(FD_NET, "client: send probe\n");
+
+ fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_PROBE, 0, &client->cmd_list);
+}
+
static int fio_client_connect_ip(struct fio_client *client)
{
struct sockaddr *addr;
client->fd = fd;
fio_client_add_hash(client);
client->state = Client_connected;
+
+ probe_client(client);
return 0;
}
sigaction(SIGTERM, &act, NULL);
}
-static void probe_client(struct fio_client *client)
-{
- dprint(FD_NET, "client: send probe\n");
-
- fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_PROBE, 0, &client->cmd_list);
-}
-
static int send_client_cmd_line(struct fio_client *client)
{
struct cmd_single_line_pdu *cslp;
continue;
}
- probe_client(client);
-
if (client->argc > 1)
send_client_cmd_line(client);
}
int ret;
ret = __fio_client_send_ini(client, filename);
- if (ret) {
- remove_client(client);
- return ret;
- }
+ if (!ret)
+ client->sent_job = 1;
- client->sent_job = 1;
return ret;
}
flist_for_each_safe(entry, tmp, &client_list) {
client = flist_entry(entry, struct fio_client, list);
- fio_client_send_ini(client, filename);
+ if (fio_client_send_ini(client, filename))
+ remove_client(client);
}
return !nr_clients;
struct cmd_start_pdu *pdu = (struct cmd_start_pdu *) cmd->payload;
client->state = Client_started;
- client->jobs = le32_to_cpu(pdu->jobs);
+ client->jobs = pdu->jobs;
}
static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
break;
case FIO_NET_CMD_SERVER_START:
client->state = Client_running;
+ if (ops->job_start)
+ ops->job_start(client, cmd);
free(cmd);
break;
- case FIO_NET_CMD_START:
- handle_start(client, cmd);
+ case FIO_NET_CMD_START: {
+ struct cmd_start_pdu *pdu = (struct cmd_start_pdu *) cmd->payload;
+
+ pdu->jobs = le32_to_cpu(pdu->jobs);
+ ops->start(client, cmd);
free(cmd);
break;
+ }
case FIO_NET_CMD_STOP: {
struct cmd_end_pdu *pdu = (struct cmd_end_pdu *) cmd->payload;
struct timeval tv;
gettimeofday(&tv, NULL);
- if (mtime_since(&eta_tv, &tv) >= 900) {
+ if (mtime_since(&eta_tv, &tv) >= ops->eta_msec) {
request_client_etas(ops);
memcpy(&eta_tv, &tv, sizeof(tv));