race bugs
Benjamin Marzinski
maintainerI was looking at the waitevent thread, and I noticed some issues. Since the cancellation type is asynchronous, the thread can get cancelled at any moment. This can cause bugs. For instance, the double removal of the dm task structure that just got fixed can still show up if the thread were cancelled after it was freed but before it was set to NULL, there were other issues like this in update_multpath. It seems like the easiest way to fix this is to set some defined cancellation points. So that's what this does.
-Ben
multipathd/main.c +2 -2
@@ -350,7 +350,6 @@ waiteventloop (struct event_thread * waidm_task_no_open_count (waiter->dmt); -pthread_testcancel ();dm_task_run (waiter->dmt);pthread_testcancel ();dm_task_destroy (waiter->dmt);
@@ -404,7 +403,6 @@ waitevent (void * et)mlockall (MCL_CURRENT |MCL_FUTURE ); waiter = (struct event_thread *)et; -pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS ,NULL );pthread_cleanup_push (free_waiter, et);while (1 ) {
@@ -413,7 +411,9 @@ waitevent (void * et)if (r <0 )break ; +pthread_testcancel ();sleep (r); +pthread_testcancel (); }pthread_cleanup_pop (1 );
Christophe Varoqui
Appliedapplied, thanks.
Quoted 45 lines · Benjamin Marzinski
I was looking at the waitevent thread, and I noticed some issues. Since the cancellation type is asynchronous, the thread can get cancelled at any moment. This can cause bugs. For instance, the double removal of the dm task structure that just got fixed can still show up if the thread were cancelled after it was freed but before it was set to NULL, there were other issues like this in
update_multpath. It seems like the easiest way to fix this is to set some defined cancellation points. So that's what this does.-Ben
diff -urpN
mp-devel/multipathd/main.cmp-devel-patched/multipathd/main.cmultipathd/main.c +2
-3@@ -350,7 +350,6 @@ waiteventloop (struct event_thread * waidm_task_no_open_count (waiter->dmt); -pthread_testcancel ();dm_task_run (waiter->dmt);pthread_testcancel ();dm_task_destroy (waiter->dmt);@@ -404,7 +403,6 @@ waitevent (void * et)mlockall (MCL_CURRENT |MCL_FUTURE ); waiter = (struct event_thread *)et; -pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS ,NULL );pthread_cleanup_push (free_waiter, et);while (1 ) {@@ -413,7 +411,9 @@ waitevent (void * et)if (r <0 )break ; +pthread_testcancel ();sleep (r); +pthread_testcancel (); }pthread_cleanup_pop (1 ); --dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel