X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=libust%2Ftracectl.c;h=c34a3ce4ad3f673393ef3df9da5f89baa965d7e8;hb=9fb49d0eb803eec381fcdc340fff3c7fe9c33742;hp=d4cb3efbcb7a97b5963106143b37640090b38822;hpb=763f41e58126afdc361006831a7daca773a9627a;p=ust.git diff --git a/libust/tracectl.c b/libust/tracectl.c index d4cb3ef..c34a3ce 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -509,7 +509,7 @@ static int do_cmd_get_subbuf_size(const char *recvbuf, struct ustcomm_source *sr return retval; } -unsigned int poweroftwo(unsigned int x) +static unsigned int poweroftwo(unsigned int x) { unsigned int power2 = 1; unsigned int hardcoded = 2147483648; /* FIX max 2^31 */ @@ -552,7 +552,6 @@ static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *sr trace = _ltt_trace_find_setup(trace_name); if(trace == NULL) { ERR("cannot find trace!"); - ltt_unlock_traces(); retval = -1; goto end; } @@ -573,9 +572,8 @@ static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *sr ERR("unable to find channel"); } - ltt_unlock_traces(); - end: + ltt_unlock_traces(); return retval; } @@ -608,7 +606,6 @@ static int do_cmd_set_subbuf_num(const char *recvbuf, struct ustcomm_source *src trace = _ltt_trace_find_setup(trace_name); if(trace == NULL) { ERR("cannot find trace!"); - ltt_unlock_traces(); retval = -1; goto end; } @@ -629,9 +626,8 @@ static int do_cmd_set_subbuf_num(const char *recvbuf, struct ustcomm_source *src ERR("unable to find channel"); } - ltt_unlock_traces(); - end: + ltt_unlock_traces(); return retval; } @@ -662,24 +658,19 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src) ltt_lock_traces(); trace = _ltt_trace_find(trace_name); - ltt_unlock_traces(); if(trace == NULL) { - char *reply; int result; WARN("Cannot find trace. It was likely destroyed by the user."); - asprintf(&reply, "%s", "NOTFOUND"); - result = ustcomm_send_reply(&ustcomm_app.server, reply, src); + result = ustcomm_send_reply(&ustcomm_app.server, "NOTFOUND", src); if(result) { ERR("ustcomm_send_reply failed"); - free(reply); retval = -1; - goto free_short_chan_name; + goto unlock_traces; } - free(reply); - goto free_short_chan_name; + goto unlock_traces; } for(i=0; inr_channels; i++) { @@ -694,7 +685,7 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src) bc = (struct blocked_consumer *) malloc(sizeof(struct blocked_consumer)); if(bc == NULL) { ERR("malloc returned NULL"); - goto free_short_chan_name; + goto unlock_traces; } bc->fd_consumer = src->fd; bc->fd_producer = buf->data_ready_fd_read; @@ -711,6 +702,9 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src) ERR("unable to find channel"); } + unlock_traces: + ltt_unlock_traces(); + free_short_chan_name: free(ch_name); @@ -765,21 +759,17 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src) ltt_lock_traces(); trace = _ltt_trace_find(trace_name); - ltt_unlock_traces(); if(trace == NULL) { WARN("Cannot find trace. It was likely destroyed by the user."); - asprintf(&reply, "%s", "NOTFOUND"); - result = ustcomm_send_reply(&ustcomm_app.server, reply, src); + result = ustcomm_send_reply(&ustcomm_app.server, "NOTFOUND", src); if(result) { ERR("ustcomm_send_reply failed"); - free(reply); retval = -1; - goto free_short_chan_name; + goto unlock_traces; } - free(reply); - goto free_short_chan_name; + goto unlock_traces; } for(i=0; inr_channels; i++) { @@ -805,7 +795,7 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src) ERR("ustcomm_send_reply failed"); free(reply); retval = -1; - goto free_channel_and_cpu; + goto unlock_traces; } free(reply); @@ -816,6 +806,8 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src) ERR("unable to find channel"); } + unlock_traces: + ltt_unlock_traces(); free_short_chan_name: free(ch_name); free_consumed_old_str: @@ -972,7 +964,7 @@ void *listener_main(void *p) DBG("trace destroy"); - result = ltt_trace_destroy(trace_name); + result = ltt_trace_destroy(trace_name, 0); if(result < 0) { ERR("ltt_trace_destroy failed"); return (void *)1; @@ -1356,7 +1348,7 @@ static void destroy_traces(void) ERR("ltt_trace_stop error"); } - result = ltt_trace_destroy("auto"); + result = ltt_trace_destroy("auto", 0); if(result == -1) { ERR("ltt_trace_destroy error"); } @@ -1461,9 +1453,14 @@ static void ust_fork(void) struct blocked_consumer *deletable_bc = NULL; int result; + /* FIXME: technically, the locks could have been taken before the fork */ DBG("ust: forking"); + + /* break lock if necessary */ + ltt_unlock_traces(); + ltt_trace_stop("auto"); - ltt_trace_destroy("auto"); + ltt_trace_destroy("auto", 1); /* Delete all active connections */ ustcomm_close_all_connections(&ustcomm_app.server); @@ -1477,8 +1474,8 @@ static void ust_fork(void) } have_listener = 0; - create_listener(); init_socket(); + create_listener(); ltt_trace_setup("auto"); result = ltt_trace_set_type("auto", "ustrelay"); if(result < 0) {