[PATCH 6/6] Fix race for sending_allowed

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

 



Sending_allowed use sync_in_process. If sync_in process is set in the
middle of sending_allowed and api->handler_fn_get, results are
unpredictable. Solution is to enlarge lock.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/coroipcs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/exec/coroipcs.c b/exec/coroipcs.c
index 36d18a4..f3161a1 100644
--- a/exec/coroipcs.c
+++ b/exec/coroipcs.c
@@ -703,6 +703,8 @@ static void *pthread_ipc_consumer (void *conn)
 
 		coroipcs_refcount_inc (conn);
 
+		api->serialize_lock();
+
 		send_ok = api->sending_allowed (conn_info->service,
 			header->id,
 			header,
@@ -723,9 +725,7 @@ static void *pthread_ipc_consumer (void *conn)
 		} else 
 		if (send_ok) {
 			api->stats_increment_value (conn_info->stats_handle, "requests");
-			api->serialize_lock();
 			api->handler_fn_get (conn_info->service, header->id) (conn_info, header);
-			api->serialize_unlock();
 		} else {
 			/*
 			 * Overload, tell library to retry
@@ -740,6 +740,9 @@ static void *pthread_ipc_consumer (void *conn)
 		}
 
 		api->sending_allowed_release (conn_info->sending_allowed_private_data);
+
+		api->serialize_unlock();
+
 		coroipcs_refcount_dec (conn);
 	}
 	pthread_exit (0);
-- 
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