client: don't leak file descriptor on exit
[fio.git] / client.c
index 678a62753021035568cec1fb54ac1f23e8d7bcca..86ac8f4179a7d488b94001bf53367a7594a9749b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -131,6 +131,9 @@ static void remove_client(struct fio_client *client)
                fio_client_dec_jobs_eta(client->eta_in_flight, client->ops->eta);
        }
 
+       close(client->fd);
+       client->fd = -1;
+
        nr_clients--;
        sum_stat_clients--;
 
@@ -373,7 +376,7 @@ int fio_client_connect(struct fio_client *client)
 
 void fio_client_terminate(struct fio_client *client)
 {
-       fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_QUIT, 0, NULL);
+       fio_net_send_quit(client->fd);
 }
 
 void fio_clients_terminate(void)
@@ -628,10 +631,11 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
 {
        int i, j;
 
-       dst->error      = le32_to_cpu(src->error);
-       dst->groupid    = le32_to_cpu(src->groupid);
-       dst->pid        = le32_to_cpu(src->pid);
-       dst->members    = le32_to_cpu(src->members);
+       dst->error              = le32_to_cpu(src->error);
+       dst->thread_number      = le32_to_cpu(src->thread_number);
+       dst->groupid            = le32_to_cpu(src->groupid);
+       dst->pid                = le32_to_cpu(src->pid);
+       dst->members            = le32_to_cpu(src->members);
 
        for (i = 0; i < 2; i++) {
                convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]);
@@ -719,6 +723,7 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd)
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
+       client_ts.thread_number = p->ts.thread_number;
        client_ts.groupid = p->ts.groupid;
 
        if (++sum_stat_nr == sum_stat_clients) {
@@ -981,6 +986,7 @@ static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd)
 
        total = nr_samples * sizeof(struct io_sample);
        ret = malloc(total + sizeof(*pdu));
+       ret->thread_number = le32_to_cpu(pdu->thread_number);
        ret->nr_samples = nr_samples;
        ret->log_type = le32_to_cpu(pdu->log_type);
        strcpy((char *) ret->name, (char *) pdu->name);
@@ -1115,7 +1121,8 @@ int fio_handle_client(struct fio_client *client)
 
                convert_stop(cmd);
                client->state = Client_stopped;
-               client->error = pdu->error;
+               client->error = le32_to_cpu(pdu->error);
+               client->signal = le32_to_cpu(pdu->signal);
                ops->stop(client, cmd);
                free(cmd);
                break;