This patch add/fixes the tmr_lib_exit_fn such that it will correctly
clean-up all timers when the process exits.

Index: services/tmr.c
===================================================================
--- services/tmr.c      (revision 1695)
+++ services/tmr.c      (working copy)
@@ -73,6 +73,7 @@
        SaTimeT call_time;
        void *timer_data;
        struct list_head list;
+       struct list_head cleanup_list;
 };
 
 DECLARE_LIST_INIT(timer_list_head);
@@ -238,16 +239,33 @@
 
 static int tmr_lib_init_fn (void *conn)
 {
+       struct tmr_pd *tmr_pd = (struct tmr_pd *) api->ipc_private_data_get 
(conn);
+
+       list_init (&tmr_pd->timer_list);
+       list_init (&tmr_pd->timer_cleanup_list);
+
        return (0);
 }
 
 static int tmr_lib_exit_fn (void *conn)
 {
+       struct timer *timer;
+       struct list_head *cleanup_list;
        struct tmr_pd *tmr_pd = (struct tmr_pd *) api->ipc_private_data_get 
(conn);
 
-       list_init (&tmr_pd->timer_list);
-       list_init (&tmr_pd->timer_cleanup_list);
+       cleanup_list = tmr_pd->timer_cleanup_list.next;
 
+       while (!list_empty (&tmr_pd->timer_cleanup_list)) {
+
+               timer = list_entry (cleanup_list, struct timer, cleanup_list);
+
+               api->timer_delete (timer->timer_handle);
+               list_del (&timer->cleanup_list);
+               free (timer);
+
+               cleanup_list = tmr_pd->timer_cleanup_list.next;
+       }
+
        return (0);
 }
 
@@ -354,6 +372,8 @@
        SaAisErrorT error = SA_AIS_OK;
        struct timer *timer = NULL;
 
+       struct tmr_pd *tmr_pd = (struct tmr_pd *) api->ipc_private_data_get 
(conn);
+
        /* DEBUG */
        log_printf (LOG_LEVEL_NOTICE, "LIB request: saTmrTimerStart { id=%u 
}\n",
                    (unsigned int)(req_lib_tmr_timerstart->timer_id));
@@ -378,7 +398,10 @@
                api->ipc_source_set (&timer->source, conn);
 
                list_init (&timer->list);
+               list_init (&timer->cleanup_list);
+
                list_add (&timer->list, &timer_list_head);
+               list_add (&timer->cleanup_list, &tmr_pd->timer_cleanup_list);
 
                switch (timer->timer_attributes.type)
                {
@@ -399,7 +422,7 @@
                         * This case is handled in the library.
                         */
                        break;
-               }
+               }       
        }
 
 error_exit:
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to