client: fix error in logging output
[fio.git] / client.c
index 6aaad0193d2b6d272bcfb31afb20bf421a278ad0..dfc172eac220ecda8571340e78d15fd5f7d14bf2 100644 (file)
--- a/client.c
+++ b/client.c
@@ -62,12 +62,7 @@ static int send_file_buf(char *buf, off_t size)
 
        cmd = malloc(sizeof(*cmd) + size);
 
-       fio_init_net_cmd(cmd);
-       cmd->opcode     = cpu_to_le16(FIO_NET_CMD_JOB_END);
-       cmd->pdu_len    = cpu_to_le32(size);
-
-       memcpy(&cmd->payload, buf, size);
-
+       fio_init_net_cmd(cmd, FIO_NET_CMD_JOB_END, buf, size);
        fio_net_cmd_crc(cmd);
 
        ret = fio_send_data(fio_client_fd, cmd, sizeof(*cmd) + size);
@@ -126,6 +121,8 @@ int fio_handle_clients(void)
 
        while (!exit_backend) {
                cmd = fio_net_cmd_read(fio_client_fd);
+               if (!cmd)
+                       continue;
 
                if (cmd->opcode == FIO_NET_CMD_ACK) {
                        free(cmd);
@@ -136,7 +133,7 @@ int fio_handle_clients(void)
                        free(cmd);
                        continue;
                }
-               printf("%s", cmd->payload);
+               fwrite(cmd->payload, cmd->pdu_len, 1, stdout);
                fflush(stdout);
                free(cmd);
        }