From 17dd17648d337479104cbdbe177214ddb69a18ce Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 4 Oct 2011 13:27:34 +0200 Subject: [PATCH] client: improve handling of non-newline text strings Only prepend hostname if this is a new line. Signed-off-by: Jens Axboe --- client.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client.c b/client.c index b632241a..12c2c377 100644 --- a/client.c +++ b/client.c @@ -25,6 +25,7 @@ struct fio_client { int fd; int state; + int skip_newline; uint16_t argc; char **argv; @@ -463,12 +464,17 @@ static int handle_client(struct fio_client *client, int one) 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); -- 2.25.1