tools/xenstored: potentially split trace_io() out message
PATCH 1/1 tools/xenstored: potentially split trace_io() out message
Today write_messages() will call trace_io() after having written the complete message to the ring buffer or socket.
In case the message can't be written in one go, split it by writing one trace entry when starting the write and one when finishing it.
---
This patch is meant to go on top of the patch "tools/xenstored: remove \"-V\" command line option" in order to not lose any possible debug information.
--- tools/xenstored/core.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
tools/xenstored/core.c +20 -10
@@ -121,7 +121,7 @@ void trace(const char *fmt, ...)static void trace_io (const struct connection *conn,const struct buffered_data *data, -int out) +const char *type) {unsigned int i;time_t now;
@@ -134,8 +134,7 @@ static void trace_io(const struct connection *conn, tm =localtime (&now);trace ("io: %s %p (d%u) %04d%02d%02d %02d:%02d:%02d %s (" , - out ?"OUT" :"IN" , conn, conn->id, - tm->tm_year +1900 , tm->tm_mon +1 , + type, conn, conn->id, tm->tm_year +1900 , tm->tm_mon +1 , tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,sockmsg_string (data->hdr.msg.type));
@@ -321,43 +320,54 @@ static bool write_messages(struct connection *conn) {int ret;struct buffered_data *out; +bool started = false; out = list_top(&conn->out_list, struct buffered_data, list);if (out ==NULL )return true;if (out->inhdr) { + started = !out->used; ret = conn->funcs->write (conn, out->hdr.raw + out->used,sizeof (out->hdr) - out->used);if (ret <0 ) -return false; + goto err; out->used += ret;if (out->used <sizeof (out->hdr)) -return true; + goto start; out->inhdr = false; out->used =0 ;/* Second write might block if non-zero. */ if (out->hdr.msg.len && !conn->domain) -return true; + goto start; } ret = conn->funcs->write (conn, out->buffer + out->used, out->hdr.msg.len - out->used);if (ret <0 ) -return false; + goto err; out->used += ret;if (out->used != out->hdr.msg.len) -return true; + goto start; -trace_io (conn, out,1 ); +trace_io (conn, out, started ?"OUT" :"OUT(END)" );free_buffered_data (out, conn);return true; + + err: +trace_io (conn, out,"OUT(ERR)" ); +return false; + + start: +if (started) +trace_io (conn, out,"OUT(START)" ); +return true; }static int undelay_request (void *_req)
@@ -2067,7 +2077,7 @@ static void process_message(struct connection *conn, struct buffered_data *in)/* At least send_error() and send_reply() expects conn->in == in */ assert (conn->in == in); -trace_io (conn, in,0 ); +trace_io (conn, in,"IN" );if ((unsigned int )type >=XS_TYPE_COUNT || !wire_funcs[type].func) {eprintf ("Client unknown operation %i" , type);
Signature · 1 line
2.35.3
Hi Juergen,
Quoted 7 lines · Juergen Gross
Today
write_messages()will calltrace_io()after having written the complete message to the ring buffer or socket.In case the message can't be written in one go, split it by writing one trace entry when starting the write and one when finishing it.
Signed-off-by Juergen Gross <[email protected]>
With one remark below:
Quoted 13 lines
---
This patch is meant to go on top of the patch "tools/xenstored: remove \"-V\" command line option" in order to not lose any possible debug information.--- tools/xenstored/core.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)tools/xenstored/core.c +0
-0
tools/xenstored/core.c void trace(const char *fmt, ...) · line 124
Quoted 5 lines
tools/xenstored/core.c +1
-1@@ -121,7 +121,7 @@ void trace(const char *fmt, ...)static void trace_io (const struct connection *conn,const struct buffered_data *data, -int out) +const char *type)
This change seems somewhat unrelated. It would be worth mentioning it in the commit message.
If you propose a new wording, I can update it while committing.
Cheers,
Signature · 1 line
Julien Grall
Quoted 35 lines · Julien Grall
Hi Juergen,
Quoted 7 lines · Juergen Gross
Today
write_messages()will calltrace_io()after having written the complete message to the ring buffer or socket.In case the message can't be written in one go, split it by writing one trace entry when starting the write and one when finishing it.
Signed-off-by Juergen Gross <[email protected]>With one remark below:
Reviewed-by Julien Grall <[email protected]>Quoted 13 lines
---
This patch is meant to go on top of the patch "tools/xenstored: remove \"-V\" command line option" in order to not lose any possible debug information.
---
tools/xenstored/core.c| 30 ++++++++++++++++++++----------1 file changed, 20 insertions(+), 10 deletions(-)tools/xenstored/core.c +0
-0tools/xenstored/core.c void trace(const char *fmt, ...) · line 123
Quoted 4 lines
tools/xenstored/core.c +1
-1@@ -121,7 +121,7 @@ void trace(const char *fmt, ...) static void trace_io(const struct connection *conn, const struct buffered_data *data, - int out) + const char *type)This change seems somewhat unrelated. It would be worth mentioning it in the commit message.
Quoted 1 line
If you propose a new wording, I can update it while committing.
What about:
In order to distinguish a complete OUT message from a split one, let the caller of trace_io specify the prefix string ("IN", "OUT", "OUT(START)", "OUT(END)") directly instead via an int.
Juergen
Hi,
Quoted 36 lines · Juergen Gross
Quoted 35 lines · Julien Grall
Hi Juergen,
Quoted 7 lines · Juergen Gross
Today
write_messages()will calltrace_io()after having written the complete message to the ring buffer or socket.In case the message can't be written in one go, split it by writing one trace entry when starting the write and one when finishing it.
Signed-off-by Juergen Gross <[email protected]>With one remark below:
Reviewed-by Julien Grall <[email protected]>Quoted 13 lines
---
This patch is meant to go on top of the patch "tools/xenstored: remove \"-V\" command line option" in order to not lose any possible debug information.
---
tools/xenstored/core.c| 30 ++++++++++++++++++++----------1 file changed, 20 insertions(+), 10 deletions(-)tools/xenstored/core.c +0
-0tools/xenstored/core.c void trace(const char *fmt, ...) · line 123
Quoted 4 lines
tools/xenstored/core.c +1
-1@@ -121,7 +121,7 @@ void trace(const char *fmt, ...) static void trace_io(const struct connection *conn, const struct buffered_data *data, - int out) + const char *type)This change seems somewhat unrelated. It would be worth mentioning it in the commit message.
Quoted 7 lines
Quoted 1 line
If you propose a new wording, I can update it while committing.
What about:
In order to distinguish a complete OUT message from a split one, let the caller of
trace_iospecify the prefix string ("IN", "OUT", "OUT(START)", "OUT(END)") directly instead via an int.
Ah... I spotted the "OUT(END)" but somehow I didn't make the connection with the update of trace_io() prototype.
It is now committed.
Cheers,
Signature · 1 line
Julien Grall