server: ensure payload larger than max is broken into pieces
[fio.git] / client.c
index d9e3857ee05e264d8ee8beb0ca2e0a4bc14a4083..1074da446be7839a9f40f2d21419504286f69140 100644 (file)
--- a/client.c
+++ b/client.c
@@ -57,22 +57,7 @@ int fio_client_connect(const char *host)
 
 static int send_file_buf(char *buf, off_t size)
 {
-       struct fio_net_cmd *cmd;
-       int ret;
-
-       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_net_cmd_crc(cmd);
-
-       ret = fio_send_data(fio_client_fd, cmd, sizeof(*cmd) + size);
-       free(cmd);
-       return ret;
+       return fio_net_send_cmd(fio_client_fd, FIO_NET_CMD_JOB, buf, size);
 }
 
 /*
@@ -133,12 +118,16 @@ int fio_handle_clients(void)
                        free(cmd);
                        continue;
                }
+               if (cmd->opcode == FIO_NET_CMD_QUIT) {
+                       free(cmd);
+                       break;
+               }
                if (cmd->opcode != FIO_NET_CMD_TEXT) {
                        printf("non text: %d\n", cmd->opcode);
                        free(cmd);
                        continue;
                }
-               printf("%s", cmd->payload);
+               fwrite(cmd->payload, cmd->pdu_len, 1, stdout);
                fflush(stdout);
                free(cmd);
        }