Add terse version 2 output format
[fio.git] / client.c
index fb678e177363c7b5a5fb4d1438627dc15653a92e..fda16b8e5e6c62233e6ff6f5e5abf763aee8a35e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -42,6 +42,8 @@ struct fio_client {
        int skip_newline;
        int is_sock;
        int disk_stats_shown;
+       unsigned int jobs;
+       int error;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
@@ -770,6 +772,25 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
                client->name = strdup((char *) probe->hostname);
 }
 
+static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+       struct cmd_start_pdu *pdu = (struct cmd_start_pdu *) cmd->payload;
+
+       client->state = Client_started;
+       client->jobs = le32_to_cpu(pdu->jobs);
+}
+
+static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+       struct cmd_end_pdu *pdu = (struct cmd_end_pdu *) cmd->payload;
+
+       client->state = Client_stopped;
+       client->error = le32_to_cpu(pdu->error);
+
+       if (client->error)
+               log_info("client <%s>: exited with error %d\n", client->hostname, client->error);
+}
+
 static int handle_client(struct fio_client *client)
 {
        struct fio_net_cmd *cmd;
@@ -830,11 +851,11 @@ static int handle_client(struct fio_client *client)
                free(cmd);
                break;
        case FIO_NET_CMD_START:
-               client->state = Client_started;
+               handle_start(client, cmd);
                free(cmd);
                break;
        case FIO_NET_CMD_STOP:
-               client->state = Client_stopped;
+               handle_stop(client, cmd);
                free(cmd);
                break;
        default:
@@ -936,7 +957,7 @@ int fio_handle_clients(void)
        struct fio_client *client;
        struct flist_head *entry;
        struct pollfd *pfds;
-       int i, ret = 0;
+       int i, ret = 0, retval = 0;
 
        gettimeofday(&eta_tv, NULL);
 
@@ -993,10 +1014,12 @@ int fio_handle_clients(void)
                                log_info("client: host=%s disconnected\n",
                                                client->hostname);
                                remove_client(client);
-                       }
+                               retval = 1;
+                       } else if (client->error)
+                               retval = 1;
                }
        }
 
        free(pfds);
-       return 0;
+       return retval;
 }