Fix: relayd: live: invalid return code on DETACH_SESSION
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Oct 2020 16:04:10 +0000 (12:04 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Oct 2020 21:03:08 +0000 (17:03 -0400)
commitf28ecb10121fd234be3cc473196ae058bc5a7ca7
treefb1ea43c51a4463235bad181168b37522575b8fb
parent061cde02380517539628893c5ed7be0de4245f3f
Fix: relayd: live: invalid return code on DETACH_SESSION

Babeltrace 2 reports an invalid return code being returned in reply to a
DETACH_SESSION command.

Reviewing the relevant Babeltrace 2 code, the logging can only be
produced if the reception of the lttng_viewer_detach_session_response
structure succeeds.

This elemininated my first guess that this was caused by the relay
daemon closing the socket before sending the reply. In that case, an
invalid status code of '0' could have been erroneously returned as a
status code since the recv() call on the socket would return 0.

It turns out that on a failure to return a packet, viewer_get_packet()
returns an error status code, but also sends a zero-initialized payload
buffer of the size of the requested packet.

This causes live clients which detach following the error of the
GET_PACKET command to interpret the still-enqueued zero-initialized
buffer as a reply to the DETACH_SESSION command. Since zero is not a
valid status code, it is correctly interpreted as a protocol error.

The reply_size is set to the header's size to only transmit the header
when an error reply is sent.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I69ed74f83404a16353d2bdbaa9f3adcdc2a03892
src/bin/lttng-relayd/live.c
This page took 0.024977 seconds and 4 git commands to generate.