X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcommon%2Fust-consumer%2Fust-consumer.c;h=cd6277f1aa42995735c95cbdf296e3cec55386cf;hb=489f70e908b9764e127115fde64fd989a265b0d3;hp=6acaacd63c942d1092ad9cdc056713f28a704462;hpb=94cc2fd1d4c93bf52c9142999ad0355ad7bc7323;p=lttng-tools.git diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 6acaacd63..cd6277f1a 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -751,6 +751,14 @@ int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, if (ret < 0) { /* Unable to handle metadata. Notify session daemon. */ ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; + /* + * Skip metadata flush on write error since the offset and len might + * not have been updated which could create an infinite loop below when + * waiting for the metadata cache to be flushed. + */ + pthread_mutex_unlock(&channel->metadata_cache->lock); + pthread_mutex_unlock(&consumer_data.lock); + goto end_free; } pthread_mutex_unlock(&channel->metadata_cache->lock); pthread_mutex_unlock(&consumer_data.lock); @@ -788,6 +796,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, * The ret value might 0 meaning an orderly shutdown but this is ok * since the caller handles this. */ + if (ret > 0) { + ret = -1; + } return ret; } if (msg.cmd_type == LTTNG_CONSUMER_STOP) { @@ -863,6 +874,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, sizeof(is_data_pending)); if (ret < 0) { DBG("Error when sending the data pending ret code: %d", ret); + goto error_fatal; } /* @@ -969,10 +981,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ret = consumer_send_status_channel(sock, channel); if (ret < 0) { /* - * There is probably a problem on the socket so the poll will get - * it and clean everything up. + * There is probably a problem on the socket. */ - goto end_nosignal; + goto error_fatal; } break; @@ -994,7 +1005,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ret = consumer_send_status_msg(sock, LTTNG_OK); if (ret < 0) { /* Somehow, the session daemon is not responding anymore. */ - goto end_nosignal; + goto error_fatal; } /* Send everything to sessiond. */ @@ -1090,14 +1101,14 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, /* Wait for more data. */ if (lttng_consumer_poll_socket(consumer_sockpoll) < 0) { - goto end_nosignal; + goto error_fatal; } ret = lttng_ustconsumer_recv_metadata(sock, key, offset, len, channel); if (ret < 0) { /* error receiving from sessiond */ - goto end_nosignal; + goto error_fatal; } else { ret_code = ret; goto end_msg_sessiond; @@ -1132,7 +1143,10 @@ end_msg_sessiond: * the caller because the session daemon socket management is done * elsewhere. Returning a negative code or 0 will shutdown the consumer. */ - (void) consumer_send_status_msg(sock, ret_code); + ret = consumer_send_status_msg(sock, ret_code); + if (ret < 0) { + goto error_fatal; + } rcu_read_unlock(); return 1; end_channel_error: