From: Jérémie Galarneau Date: Thu, 6 Aug 2015 02:03:29 +0000 (-0400) Subject: Fix: Discard disable event command filter payload X-Git-Tag: v2.6.1~79 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=abfab6f84484021fbdb4c53618b9bd5aed9a7608;p=lttng-tools.git Fix: Discard disable event command filter payload 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 --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 36d154e1f..900df559a 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3168,8 +3168,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);