Преглед изворни кода

Currently saLckResourceUnlockAsync leaves the lockid in the handle database even
when the lock has been unlocked. This can cause exec crashes if the lock is
unlocked twice.

This patch adds an extra field to the res_lib_lck_resourceunlockasync structure
so that the library can remove the lock from the handle database when the lock
is unlocked successfully, as well as code to do it, obviously.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1383 fd59a12c-fef9-0310-b244-a6a79926bd2f

Patrick Caulfield пре 18 година
родитељ
комит
d147700e95
3 измењених фајлова са 14 додато и 1 уклоњено
  1. 1 0
      exec/lck.c
  2. 1 0
      include/ipc_lck.h
  3. 12 1
      lib/lck.c

+ 1 - 0
exec/lck.c

@@ -1282,6 +1282,7 @@ error_exit:
 			res_lib_lck_resourceunlockasync.header.error = error;
 			res_lib_lck_resourceunlockasync.invocation =
 				req_exec_lck_resourceunlock->invocation;
+			res_lib_lck_resourceunlockasync.lockId = req_exec_lck_resourceunlock->lock_id;
 
 			openais_conn_send_response (
 				openais_conn_partner_get(req_exec_lck_resourceunlock->source.conn),

+ 1 - 0
include/ipc_lck.h

@@ -158,6 +158,7 @@ struct res_lib_lck_resourceunlock {
 struct res_lib_lck_resourceunlockasync {
 	mar_res_header_t header;
 	SaInvocationT invocation;
+	SaLckLockIdT lockId;
 };
 
 struct req_lib_lck_lockpurge {

+ 12 - 1
lib/lck.c

@@ -340,7 +340,7 @@ saLckDispatch (
 	struct message_overlay dispatch_data;
 	struct res_lib_lck_lockwaitercallback *res_lib_lck_lockwaitercallback;
 	struct res_lib_lck_resourceopenasync *res_lib_lck_resourceopenasync = NULL;
-	struct res_lib_lck_resourcelockasync *res_lib_lck_resourcelockasync;
+	struct res_lib_lck_resourcelockasync *res_lib_lck_resourcelockasync = NULL;
 	struct res_lib_lck_resourceunlockasync *res_lib_lck_resourceunlockasync;
 
 
@@ -519,6 +519,17 @@ saLckDispatch (
 			callbacks.saLckResourceUnlockCallback (
 				res_lib_lck_resourceunlockasync->invocation,
 				res_lib_lck_resourceunlockasync->header.error);
+
+			if (res_lib_lck_resourcelockasync->header.error == SA_AIS_OK) {
+				error = saHandleInstanceGet (&lckLockIdHandleDatabase,
+							     res_lib_lck_resourceunlockasync->lockId,
+							     (void *)&lckLockIdInstance);
+				if (error == SA_AIS_OK) {
+					saHandleInstancePut (&lckLockIdHandleDatabase, res_lib_lck_resourceunlockasync->lockId);
+
+					saHandleDestroy (&lckLockIdHandleDatabase, res_lib_lck_resourceunlockasync->lockId);
+				}
+			}
 			break;
 #ifdef NOT_DONE_YET