client: improve handling of non-newline text strings
Only prepend hostname if this is a new line.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/client.c b/client.c
index b632241..12c2c37 100644
--- a/client.c
+++ b/client.c
@@ -25,6 +25,7 @@
int fd;
int state;
+ int skip_newline;
uint16_t argc;
char **argv;
@@ -463,12 +464,17 @@
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);
+ client->skip_newline = strchr(buf, '\n') == NULL;
free(cmd);
break;
+ }
case FIO_NET_CMD_TS:
handle_ts(cmd);
free(cmd);