+/*
+ * Receive a reply command status message from the consumer. Consumer socket
+ * lock MUST be acquired before calling this function.
+ *
+ * Return 0 on success, -1 on recv error or a negative lttng error code which
+ * was possibly returned by the consumer.
+ */
+int consumer_recv_status_reply(struct consumer_socket *sock)
+{
+ int ret;
+ struct lttcomm_consumer_status_msg reply;
+
+ assert(sock);
+
+ ret = lttcomm_recv_unix_sock(sock->fd, &reply, sizeof(reply));
+ if (ret <= 0) {
+ if (ret == 0) {
+ /* Orderly shutdown. Don't return 0 which means success. */
+ ret = -1;
+ }
+ /* The above call will print a PERROR on error. */
+ DBG("Fail to receive status reply on sock %d", sock->fd);
+ goto end;
+ }
+
+ if (reply.ret_code == LTTNG_OK) {
+ /* All good. */
+ ret = 0;
+ } else {
+ ret = -reply.ret_code;
+ DBG("Consumer ret code %d", reply.ret_code);
+ }
+
+end:
+ return ret;
+}
+