add NOTFOUND reply for get_subbuf and put_subbuf commands
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Thu, 18 Feb 2010 15:02:04 +0000 (10:02 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Thu, 18 Feb 2010 15:02:45 +0000 (10:02 -0500)
libust/tracectl.c
ustd/ustd.c

index 3a5a3385d2522ae094046cef4d570cc61dd303eb..4447b92d676c04aebbe54eb9e39504bb5aa04ecb 100644 (file)
@@ -539,8 +539,20 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src)
        ltt_unlock_traces();
 
        if(trace == NULL) {
-               ERR("cannot find trace!");
-               retval = -1;
+               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);
+               if(result) {
+                       ERR("ustcomm_send_reply failed");
+                       free(reply);
+                       retval = -1;
+                       goto free_short_chan_name;
+               }
+
+               free(reply);
                goto free_short_chan_name;
        }
 
@@ -594,6 +606,7 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src)
        long consumed_old;
        char *consumed_old_str;
        char *endptr;
+       char *reply = NULL;
 
        DBG("put_subbuf");
 
@@ -629,8 +642,17 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src)
        ltt_unlock_traces();
 
        if(trace == NULL) {
-               ERR("cannot find trace!");
-               retval = -1;
+               WARN("Cannot find trace. It was likely destroyed by the user.");
+               asprintf(&reply, "%s", "NOTFOUND");
+               result = ustcomm_send_reply(&ustcomm_app.server, reply, src);
+               if(result) {
+                       ERR("ustcomm_send_reply failed");
+                       free(reply);
+                       retval = -1;
+                       goto free_short_chan_name;
+               }
+
+               free(reply);
                goto free_short_chan_name;
        }
 
@@ -639,7 +661,6 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src)
 
                if(!strcmp(trace->channels[i].channel_name, ch_name)) {
                        struct ust_buffer *buf = channel->buf[ch_cpu];
-                       char *reply;
 
                        found = 1;
 
@@ -666,15 +687,15 @@ static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src)
                }
        }
        if(found == 0) {
-               ERR("get_subbuf_size: unable to find channel");
+               ERR("unable to find channel");
        }
 
-       free_channel_and_cpu:
-       free(channel_and_cpu);
-       free_consumed_old_str:
-       free(consumed_old_str);
        free_short_chan_name:
        free(ch_name);
+       free_consumed_old_str:
+       free(consumed_old_str);
+       free_channel_and_cpu:
+       free(channel_and_cpu);
 
        end:
        return retval;
index b38593b36b0d65cc9f89b2eea565aed612d97c58..7882e34544278f4cd68a08303670e8b8d35d75ea 100644 (file)
@@ -160,6 +160,14 @@ int put_subbuffer(struct buffer_info *buf)
                DBG("subbuffer put %s", buf->name);
                retval = PUT_SUBBUF_OK;
        }
+       else if(!strcmp(received_msg, "NOTFOUND")) {
+               WARN("For buffer %s, the trace was not found. This likely means it was destroyed by the user.", buf->name);
+               /* However, maybe this was not the last subbuffer. So
+                * we return the program died.
+                */
+               retval = PUT_SUBBUF_DIED;
+               goto end_rep;
+       }
        else {
                DBG("put_subbuffer: received error, we were pushed");
                retval = PUT_SUBBUF_PUSHED;
This page took 0.027692 seconds and 4 git commands to generate.