From 47b7e2f9d1199c32f87138f4c226e9c5153c7968 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 5 Aug 2015 22:03:29 -0400 Subject: [PATCH] Fix: Discard disable event command filter payload MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit liblttng-ctl sends both the filter expression and filter bytecode whenever lttng_disable_event_ext() is used _or_ when it is used implicitly by lttng_disable_event() on an Agent domain (Log4j, JUL or Python). As of now, the session daemon ignores this filter payload. However, on some rare occasions (the frequency of which depends on the system's configuration and load), the second call to sendmsg() done by liblttng-ctl could block and return an error when the session daemon closed the socket (EPIPE). This fix ensures the payload is received and discarded by the session daemon, which in turn allows the client to handle the session daemon's reply to the command. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 792f519ab..d284debd6 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3267,8 +3267,34 @@ skip_domain: } case LTTNG_DISABLE_EVENT: { + + /* + * FIXME: handle filter; for now we just receive the filter's + * bytecode along with the filter expression which are sent by + * liblttng-ctl and discard them. + * + * This fixes an issue where the client may block while sending + * the filter payload and encounter an error because the session + * daemon closes the socket without ever handling this data. + */ + size_t count = cmd_ctx->lsm->u.disable.expression_len + + cmd_ctx->lsm->u.disable.bytecode_len; + + if (count) { + char data[LTTNG_FILTER_MAX_LEN]; + + DBG("Discarding disable event command payload of size %zu", count); + while (count) { + ret = lttcomm_recv_unix_sock(sock, data, + count > sizeof(data) ? sizeof(data) : count); + if (ret < 0) { + goto error; + } + + count -= (size_t) ret; + } + } /* FIXME: passing packed structure to non-packed pointer */ - /* TODO: handle filter */ ret = cmd_disable_event(cmd_ctx->session, cmd_ctx->lsm->domain.type, cmd_ctx->lsm->u.disable.channel_name, &cmd_ctx->lsm->u.disable.event); -- 2.34.1