[Openais] [PATCH]: openais/trunk: Only send response/callback when unlocking pending locks

Ryan O'Hara rohara at redhat.com
Tue Jun 9 12:16:05 PDT 2009


When unlocking a pending lock request, we must send a response (or
callback) to the library indicating an error occured. This patch
simply adds a check that the lock is pending before we send the
response.

Without this fix, callbacks are sent when they are not needed. For
example, if we close a resource while holding locks we will hit this
code (in lck_unlock) that will incorrectly send callbacks to the
library.

Ryan

-------------- next part --------------
Index: lck.c
===================================================================
--- lck.c	(revision 1948)
+++ lck.c	(working copy)
@@ -1810,13 +1810,19 @@
 		 */
 		list_del (&resource_lock->list);
 
-		if (resource_lock->timer_handle != 0) {
+		/*
+		 * If we are unlocking a lock that was queued, we must
+		 * send a response/callback to the library.
+		 */
+		if (resource_lock->lock_status == 0) {
+			if (resource_lock->timer_handle != 0) {
 				api->timer_delete (resource_lock->timer_handle);
-				lck_resourcelock_response_send (resource_lock, SA_AIS_ERR_TIMEOUT); /* ? */
+				lck_resourcelock_response_send (resource_lock, SA_AIS_ERR_TIMEOUT);
 			}
 			else {
-				lck_lockgrant_callback_send (resource_lock, SA_AIS_ERR_NOT_EXIST); /* ? */
+				lck_lockgrant_callback_send (resource_lock, SA_AIS_ERR_NOT_EXIST);
 			}
+		}
 	}
 
 	/*


More information about the Openais mailing list