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

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);
                        }
+               }
        }
 
        /*
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to