client: remove debug printf() for compressed iolog
[fio.git] / client.c
index df13254a39f0ba2517c85b737b311899e590a254..515cbf2e178aae746d04a61ccfa0aab4b2d976c6 100644 (file)
--- a/client.c
+++ b/client.c
@@ -33,6 +33,8 @@ 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);
 
+static void convert_text(struct fio_net_cmd *cmd);
+
 struct client_ops fio_client_ops = {
        .text           = handle_text,
        .disk_util      = handle_du,
@@ -215,12 +217,32 @@ static int fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
        return 1;
 }
 
+static void fio_drain_client_text(struct fio_client *client)
+{
+       do {
+               struct fio_net_cmd *cmd;
+
+               cmd = fio_net_recv_cmd(client->fd, false);
+               if (!cmd)
+                       break;
+
+               if (cmd->opcode == FIO_NET_CMD_TEXT) {
+                       convert_text(cmd);
+                       client->ops->text(client, cmd);
+               }
+
+               free(cmd);
+       } while (1);
+}
+
 static void remove_client(struct fio_client *client)
 {
        assert(client->refs);
 
        dprint(FD_NET, "client: removed <%s>\n", client->hostname);
 
+       fio_drain_client_text(client);
+
        if (!flist_empty(&client->list))
                flist_del_init(&client->list);
 
@@ -1438,7 +1460,6 @@ static struct cmd_iolog_pdu *convert_iolog(struct fio_net_cmd *cmd,
                return NULL;
 #endif
                ret = convert_iolog_gz(cmd, pdu);
-               printf("compressed iolog, %p\n", ret);
                if (!ret) {
                        log_err("fio: failed decompressing log\n");
                        return NULL;
@@ -1485,8 +1506,8 @@ static void sendfile_reply(int fd, struct cmd_sendfile_reply *rep,
        fio_net_send_cmd(fd, FIO_NET_CMD_SENDFILE, rep, size, &tag, NULL);
 }
 
-static int send_file(struct fio_client *client, struct cmd_sendfile *pdu,
-                    uint64_t tag)
+static int fio_send_file(struct fio_client *client, struct cmd_sendfile *pdu,
+                        uint64_t tag)
 {
        struct cmd_sendfile_reply *rep;
        struct stat sb;
@@ -1526,7 +1547,7 @@ int fio_handle_client(struct fio_client *client)
 
        dprint(FD_NET, "client: handle %s\n", client->hostname);
 
-       cmd = fio_net_recv_cmd(client->fd);
+       cmd = fio_net_recv_cmd(client->fd, true);
        if (!cmd)
                return 0;
 
@@ -1636,7 +1657,7 @@ int fio_handle_client(struct fio_client *client)
                }
        case FIO_NET_CMD_SENDFILE: {
                struct cmd_sendfile *pdu = (struct cmd_sendfile *) cmd->payload;
-               send_file(client, pdu, cmd->tag);
+               fio_send_file(client, pdu, cmd->tag);
                break;
                }
        case FIO_NET_CMD_JOB_OPT: {