client: improve handling of non-newline text strings
authorJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 11:27:34 +0000 (13:27 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 11:27:34 +0000 (13:27 +0200)
Only prepend hostname if this is a new line.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c

index b632241aec791d57aaa18df4427538c635a2cb6d..12c2c37732c3321c2a08c2e573a4b9c2c79cd12f 100644 (file)
--- a/client.c
+++ b/client.c
@@ -25,6 +25,7 @@ struct fio_client {
        int fd;
 
        int state;
        int fd;
 
        int state;
+       int skip_newline;
 
        uint16_t argc;
        char **argv;
 
        uint16_t argc;
        char **argv;
@@ -463,12 +464,17 @@ static int handle_client(struct fio_client *client, int one)
                        free(cmd);
                        done = 1;
                        break;
                        free(cmd);
                        done = 1;
                        break;
-               case FIO_NET_CMD_TEXT:
-                       fprintf(f_out, "Client <%s>: ", client->hostname);
-                       fwrite(cmd->payload, cmd->pdu_len, 1, f_out);
+               case FIO_NET_CMD_TEXT: {
+                       const char *buf = (const char *) cmd->payload;
+
+                       if (!client->skip_newline)
+                               fprintf(f_out, "Client <%s>: ", client->hostname);
+                       fwrite(buf, cmd->pdu_len, 1, f_out);
                        fflush(f_out);
                        fflush(f_out);
+                       client->skip_newline = strchr(buf, '\n') == NULL;
                        free(cmd);
                        break;
                        free(cmd);
                        break;
+                       }
                case FIO_NET_CMD_TS:
                        handle_ts(cmd);
                        free(cmd);
                case FIO_NET_CMD_TS:
                        handle_ts(cmd);
                        free(cmd);