}
case LTTNG_CONSUMER_DATA_AVAILABLE:
{
- rcu_read_unlock();
- return -ENOSYS;
+ int32_t ret;
+ uint64_t id = msg.u.data_available.session_id;
+
+ DBG("Kernel consumer data available command for id %" PRIu64, id);
+
+ ret = consumer_data_available(id);
+
+ /* Send back returned value to session daemon */
+ ret = lttcomm_send_unix_sock(sock, &ret, sizeof(ret));
+ if (ret < 0) {
+ PERROR("send data available ret code");
+ }
+ break;
}
default:
goto end_nosignal;
*/
ret = pthread_mutex_trylock(&stream->lock);
if (ret == EBUSY) {
- goto data_not_available;
+ /* Data not available */
+ ret = 0;
+ goto end;
}
/* The stream is now locked so we can do our ustctl calls */
/* There is still data so let's put back this subbuffer. */
ret = kernctl_put_subbuf(stream->wait_fd);
assert(ret == 0);
- pthread_mutex_unlock(&stream->lock);
- goto data_not_available;
+ goto end_unlock;
}
/* Data is available to be read for this stream. */
- pthread_mutex_unlock(&stream->lock);
- return 1;
+ ret = 1;
-data_not_available:
- return 0;
+end_unlock:
+ pthread_mutex_unlock(&stream->lock);
+end:
+ return ret;
}