Fix session list deadlock
[lttng-tools.git] / ltt-sessiond / session.c
index b13f4a916c8963357cea305d4677649a7f955f05..ae83e45aec1b7610992772d48b35615a8adb1ba1 100644 (file)
@@ -144,23 +144,20 @@ struct ltt_session *session_find_by_name(char *name)
  *
  * Return -1 if no session is found.  On success, return 1;
  */
-int session_destroy(char *name)
+int session_destroy(struct ltt_session *session)
 {
-       struct ltt_session *iter, *tmp;
-
-       session_lock_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);
-                       free(iter->name);
-                       free(iter->path);
-                       pthread_mutex_destroy(&iter->lock);
-                       free(iter);
-                       break;
-               }
+       /* Safety check */
+       if (session == NULL) {
+               ERR("Session pointer was null on session destroy");
+               return LTTCOMM_OK;
        }
-       session_unlock_list();
+
+       DBG("Destroying session %s", session->name);
+       del_session_list(session);
+       free(session->name);
+       free(session->path);
+       pthread_mutex_destroy(&session->lock);
+       free(session);
 
        return LTTCOMM_OK;
 }
This page took 0.022874 seconds and 4 git commands to generate.