Fix safe list iteration
authorDavid Goulet <david.goulet@polymtl.ca>
Tue, 26 Jul 2011 14:59:20 +0000 (10:59 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Tue, 26 Jul 2011 14:59:20 +0000 (10:59 -0400)
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-sessiond/main.c
ltt-sessiond/session.c
ltt-sessiond/trace.c

index 380aa7d9c95e5cb40c9df1f6b27ee98f00587df0..bba8aa64d4dfebcb4a3c35150969c72070af7fb2 100644 (file)
@@ -150,7 +150,7 @@ static void cleanup()
 {
        int ret;
        char *cmd;
-       struct ltt_session *sess;
+       struct ltt_session *sess, *stmp;
 
        DBG("Cleaning up");
 
@@ -184,7 +184,7 @@ static void cleanup()
                pthread_mutex_destroy(&session_list_ptr->lock);
 
                /* Cleanup ALL session */
-               cds_list_for_each_entry(sess, &session_list_ptr->head, list) {
+               cds_list_for_each_entry_safe(sess, stmp, &session_list_ptr->head, list) {
                        teardown_kernel_session(sess);
                        // TODO complete session cleanup (including UST)
                }
index 16f137eb0022f24af4a3a35d0d3e045bf022484d..ff79bf2a969bde74e1045f7c0c126e6eea46df16 100644 (file)
@@ -156,10 +156,10 @@ struct ltt_session *find_session_by_name(char *name)
 int destroy_session(char *name)
 {
        int found = -1;
-       struct ltt_session *iter;
+       struct ltt_session *iter, *tmp;
 
        lock_session_list();
-       cds_list_for_each_entry(iter, &ltt_session_list.head, list) {
+       cds_list_for_each_entry_safe(iter, tmp, &ltt_session_list.head, list) {
                if (strcmp(iter->name, name) == 0) {
                        DBG("Destroying session %s", iter->name);
                        del_session_list(iter);
index b6138f8f5837ea61b9e9e2fc31d7a2242e81c97e..1509edacdf048e92fef749cad90ac8c30e09af7a 100644 (file)
@@ -311,8 +311,8 @@ void trace_destroy_kernel_event(struct ltt_kernel_event *event)
 
 void trace_destroy_kernel_channel(struct ltt_kernel_channel *channel)
 {
-       struct ltt_kernel_stream *stream;
-       struct ltt_kernel_event *event;
+       struct ltt_kernel_stream *stream, *stmp;
+       struct ltt_kernel_event *event, *etmp;
 
        DBG("[trace] Closing channel fd %d", channel->fd);
        /* Close kernel fd */
@@ -322,12 +322,12 @@ void trace_destroy_kernel_channel(struct ltt_kernel_channel *channel)
        free(channel->channel);
 
        /* For each stream in the channel list */
-       cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
+       cds_list_for_each_entry_safe(stream, stmp, &channel->stream_list.head, list) {
                trace_destroy_kernel_stream(stream);
        }
 
        /* For each event in the channel list */
-       cds_list_for_each_entry(event, &channel->events_list.head, list) {
+       cds_list_for_each_entry_safe(event, etmp, &channel->events_list.head, list) {
                trace_destroy_kernel_event(event);
        }
 
@@ -349,7 +349,7 @@ void trace_destroy_kernel_metadata(struct ltt_kernel_metadata *metadata)
 
 void trace_destroy_kernel_session(struct ltt_kernel_session *session)
 {
-       struct ltt_kernel_channel *channel;
+       struct ltt_kernel_channel *channel, *ctmp;
 
        DBG("[trace] Closing session fd %d", session->fd);
        /* Close kernel fds */
@@ -363,7 +363,7 @@ void trace_destroy_kernel_session(struct ltt_kernel_session *session)
                trace_destroy_kernel_metadata(session->metadata);
        }
 
-       cds_list_for_each_entry(channel, &session->channel_list.head, list) {
+       cds_list_for_each_entry_safe(channel, ctmp, &session->channel_list.head, list) {
                trace_destroy_kernel_channel(channel);
        }
 
This page took 0.037143 seconds and 4 git commands to generate.