[PATCH 2/2] Handle sync and service unload correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When sync started and service is unloaded in meantime, it can happen that
sync will call sync_* functions on unloaded service.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/main.c |    4 ++++
 exec/sync.c |   25 ++++++++++++++++++-------
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index 5bccb87..f03d8fe 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -285,6 +285,10 @@ static int corosync_sync_callbacks_retrieve (
 		return (-1);
 	}
 
+	if (callbacks == NULL) {
+		return (0);
+	}
+
 	callbacks->name = corosync_service[service_id]->name;
 
 	callbacks->sync_init = corosync_service[service_id]->sync_init;
diff --git a/exec/sync.c b/exec/sync.c
index b09ea53..0ffe5ce 100644
--- a/exec/sync.c
+++ b/exec/sync.c
@@ -231,7 +231,10 @@ static void sync_barrier_handler (unsigned int nodeid, const void *msg)
 		log_printf (LOGSYS_LEVEL_DEBUG, "Committing synchronization for %s",
 			my_service_list[my_processing_idx].name);
 		my_service_list[my_processing_idx].state = ACTIVATE;
-		my_service_list[my_processing_idx].sync_activate ();
+
+		if (my_sync_callbacks_retrieve(my_processing_idx, NULL) != -1) {
+			my_service_list[my_processing_idx].sync_activate ();
+		}
 
 		my_processing_idx += 1;
 		if (my_service_list_entries == my_processing_idx) {
@@ -544,14 +547,20 @@ static int schedwrk_processor (const void *context)
 			}
 		}
 
-		my_service_list[my_processing_idx].sync_init (my_trans_list,
-			my_trans_list_entries, my_member_list,
-			my_member_list_entries,
-			&my_ring_id);
+		if (my_sync_callbacks_retrieve(my_processing_idx, NULL) != -1) {
+			my_service_list[my_processing_idx].sync_init (my_trans_list,
+				my_trans_list_entries, my_member_list,
+				my_member_list_entries,
+				&my_ring_id);
+		}
 	}
 	if (my_service_list[my_processing_idx].state == PROCESS) {
 		my_service_list[my_processing_idx].state = PROCESS;
-		res = my_service_list[my_processing_idx].sync_process ();
+		if (my_sync_callbacks_retrieve(my_processing_idx, NULL) != -1) {
+			res = my_service_list[my_processing_idx].sync_process ();
+		} else {
+			res = 0;
+		}
 		if (res == 0) {
 			sync_barrier_enter();
 		} else {
@@ -595,7 +604,9 @@ void sync_abort (void)
 	ENTER();
 	if (my_state == SYNC_PROCESS) {
 		schedwrk_destroy (my_schedwrk_handle);
-		my_service_list[my_processing_idx].sync_abort ();
+		if (my_sync_callbacks_retrieve(my_processing_idx, NULL) != -1) {
+			my_service_list[my_processing_idx].sync_abort ();
+		}
 	}
 
 	/* this will cause any "old" barrier messages from causing
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux