lttng_consumer_send_error sends an lttcomm_return_code to the session
daemon. However, the size of lttcomm_sessiond_command was used.
This was probably missed since the function accepts an integer instead
of a proper enum type.
The size accepted by the function is changed to use lttcomm_return_code
and the size of a fixed-size type is used to send the error code to the
session daemon.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib6a04969dd82857e3b8ac2ca2545cfb098b2d04f
DBG2("Receiving code from consumer err_sock");
DBG2("Receiving code from consumer err_sock");
- /* Getting status code from kconsumerd */
- ret = lttcomm_recv_unix_sock(sock, &code,
- sizeof(enum lttcomm_return_code));
+ /* Getting status code from consumerd */
+ {
+ int32_t comm_code = 0;
+
+ ret = lttcomm_recv_unix_sock(sock, &comm_code, sizeof(comm_code));
+ code = (typeof(code)) comm_code;
+ }
if (ret <= 0) {
mark_thread_intialization_as_failed(notifiers);
goto error;
if (ret <= 0) {
mark_thread_intialization_as_failed(notifiers);
goto error;
goto error;
}
health_code_update();
goto error;
}
health_code_update();
- /* Wait for any kconsumerd error */
- ret = lttcomm_recv_unix_sock(sock, &code,
- sizeof(enum lttcomm_return_code));
+ /* Wait for any consumerd error */
+ {
+ int32_t comm_code = 0;
+
+ ret = lttcomm_recv_unix_sock(
+ sock, &comm_code, sizeof(comm_code));
+ code = (typeof(code)) comm_code;
+ }
if (ret <= 0) {
ERR("consumer closed the command socket");
goto error;
if (ret <= 0) {
ERR("consumer closed the command socket");
goto error;
* Send return code to the session daemon.
* If the socket is not defined, we return 0, it is not a fatal error
*/
* Send return code to the session daemon.
* If the socket is not defined, we return 0, it is not a fatal error
*/
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd)
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx,
+ enum lttcomm_return_code error_code)
{
if (ctx->consumer_error_socket > 0) {
{
if (ctx->consumer_error_socket > 0) {
- return lttcomm_send_unix_sock(ctx->consumer_error_socket, &cmd,
- sizeof(enum lttcomm_sessiond_command));
+ const int32_t comm_code = (int32_t) error_code;
+
+ return lttcomm_send_unix_sock(
+ ctx->consumer_error_socket, &comm_code, sizeof(comm_code));
* Returns the return code of sendmsg : the number of bytes transmitted or -1
* on error.
*/
* Returns the return code of sendmsg : the number of bytes transmitted or -1
* on error.
*/
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx,
+ enum lttcomm_return_code error_code);
/*
* Called from signal handler to ensure a clean exit.
/*
* Called from signal handler to ensure a clean exit.