Просмотр исходного кода

lock service locks up under certain conditions this patch fixes that problem
from Mark



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

Steven Dake 20 лет назад
Родитель
Сommit
1020c951b3
2 измененных файлов с 57 добавлено и 52 удалено
  1. 48 44
      exec/lck.c
  2. 9 8
      lib/lck.c

+ 48 - 44
exec/lck.c

@@ -621,21 +621,23 @@ static int message_handler_req_exec_lck_resourceopen (
 	/*
 	 * Setup connection information and mark resource as referenced
 	 */
-	log_printf (LOG_LEVEL_DEBUG, "Lock resource opened is %p\n", resource);
-	resource_cleanup = malloc (sizeof (struct resource_cleanup));
-	if (resource_cleanup == 0) {
-		free (resource);
-		error = SA_AIS_ERR_NO_MEMORY;
-	} else {
-		list_init (&resource_cleanup->list);
-		list_init (&resource_cleanup->resource_lock_list_head);
-		resource_cleanup->resource = resource;
-		resource_cleanup->resource_handle = req_exec_lck_resourceopen->resource_handle;
-		list_add (
-			&resource_cleanup->list,
-			&req_exec_lck_resourceopen->source.conn_info->ais_ci.u.liblck_ci.resource_cleanup_list);
+	if (message_source_is_local (&req_exec_lck_resourceopen->source)) {
+		log_printf (LOG_LEVEL_DEBUG, "Lock resource opened is %p\n", resource);
+		resource_cleanup = malloc (sizeof (struct resource_cleanup));
+		if (resource_cleanup == 0) {
+			free (resource);
+			error = SA_AIS_ERR_NO_MEMORY;
+		} else {
+			list_init (&resource_cleanup->list);
+			list_init (&resource_cleanup->resource_lock_list_head);
+			resource_cleanup->resource = resource;
+			resource_cleanup->resource_handle = req_exec_lck_resourceopen->resource_handle;
+			list_add (
+				&resource_cleanup->list,
+				&req_exec_lck_resourceopen->source.conn_info->ais_ci.u.liblck_ci.resource_cleanup_list);
+		}
+		resource->refcount += 1;
 	}
-	resource->refcount += 1;
 	
 	
 	/*
@@ -1043,45 +1045,47 @@ static int message_handler_req_exec_lck_resourcelock (
 	/*
 	 * Add resource lock to cleanup handler for this api resource instance
 	 */
-	resource_cleanup = lck_resource_cleanup_find (
-		resource_lock->callback_source.conn_info,
-		req_exec_lck_resourcelock->resource_handle);
+	if (message_source_is_local (&req_exec_lck_resourcelock->source)) {
+		resource_cleanup = lck_resource_cleanup_find (
+			resource_lock->callback_source.conn_info,
+			req_exec_lck_resourcelock->resource_handle);
 
-	assert (resource_cleanup);
-		
-	list_add (&resource_lock->resource_cleanup_list,
-		&resource_cleanup->resource_lock_list_head);
+		assert (resource_cleanup);
+			
+		list_add (&resource_lock->resource_cleanup_list,
+			&resource_cleanup->resource_lock_list_head);
+
+		/*
+		 * If lock queued by lock algorithm, dont send response to library now
+		 */
+		if (resource_lock->lock_status != SA_LCK_LOCK_NO_STATUS) {
+			/*
+			 * If lock granted or denied, deliver callback or 
+			 * response to library for non-async calls
+			 */
+			lock_response_deliver (
+				&req_exec_lck_resourcelock->source,
+				resource_lock,
+				SA_AIS_OK);
+		} else {
+			memcpy (&resource_lock->response_source,
+				&req_exec_lck_resourcelock->source,
+				sizeof (struct message_source));
+		}
 
-	/*
-	 * If lock queued by lock algorithm, dont send response to library now
-	 */
-	if (resource_lock->lock_status != SA_LCK_LOCK_NO_STATUS) {
 		/*
-		 * If lock granted or denied, deliver callback or 
-		 * response to library for non-async calls
+		 * Deliver async response to library
 		 */
-		lock_response_deliver (
+		req_exec_lck_resourcelock->source.conn_info =
+			req_exec_lck_resourcelock->source.conn_info->conn_info_partner;
+		resource_lock_async_deliver (
 			&req_exec_lck_resourcelock->source,
 			resource_lock,
 			SA_AIS_OK);
-	} else {
-		memcpy (&resource_lock->response_source,
-			&req_exec_lck_resourcelock->source,
-			sizeof (struct message_source));
+		req_exec_lck_resourcelock->source.conn_info =
+			req_exec_lck_resourcelock->source.conn_info->conn_info_partner;
 	}
 
-	/*
-	 * Deliver async response to library
-	 */
-	req_exec_lck_resourcelock->source.conn_info =
-		req_exec_lck_resourcelock->source.conn_info->conn_info_partner;
-	resource_lock_async_deliver (
-		&req_exec_lck_resourcelock->source,
-		resource_lock,
-		SA_AIS_OK);
-	req_exec_lck_resourcelock->source.conn_info =
-		req_exec_lck_resourcelock->source.conn_info->conn_info_partner;
-
 error_exit:
 	return (0);
 }

+ 9 - 8
lib/lck.c

@@ -712,7 +712,7 @@ saLckResourceOpenAsync (
 	SaLckResourceHandleT lckResourceHandle;
 	SaAisErrorT error;
 	struct req_lib_lck_resourceopen req_lib_lck_resourceopen;
-	struct res_lib_lck_resourceopen res_lib_lck_resourceopen;
+	struct res_lib_lck_resourceopenasync res_lib_lck_resourceopenasync;
 
 	error = saHandleInstanceGet (&lckHandleDatabase, lckHandle,
 		(void *)&lckInstance);
@@ -743,6 +743,7 @@ saLckResourceOpenAsync (
 	lckResourceInstance->lckResourceHandle = lckResourceHandle;
 	lckResourceInstance->resourceOpenFlags = resourceOpenFlags;
 
+	memcpy (&lckResourceInstance->lockResourceName, lockResourceName, sizeof (SaNameT));
 	req_lib_lck_resourceopen.header.size = sizeof (struct req_lib_lck_resourceopen);
 	req_lib_lck_resourceopen.header.id = MESSAGE_REQ_LCK_RESOURCEOPENASYNC;
 	req_lib_lck_resourceopen.invocation = invocation;
@@ -755,8 +756,8 @@ saLckResourceOpenAsync (
 	error = saSendReceiveReply (lckResourceInstance->response_fd, 
 		&req_lib_lck_resourceopen,
 		sizeof (struct req_lib_lck_resourceopen),
-		&res_lib_lck_resourceopen,
-		sizeof (struct res_lib_lck_resourceopen));
+		&res_lib_lck_resourceopenasync,
+		sizeof (struct res_lib_lck_resourceopenasync));
 
 	pthread_mutex_unlock (&lckInstance->response_mutex);
 
@@ -764,7 +765,7 @@ saLckResourceOpenAsync (
 		saHandleInstancePut (&lckResourceHandleDatabase,
 			lckResourceHandle);
 		saHandleInstancePut (&lckHandleDatabase, lckHandle);
-		return (res_lib_lck_resourceopen.header.error);
+		return (res_lib_lck_resourceopenasync.header.error);
 	}
 
 	saHandleInstancePut (&lckResourceHandleDatabase, lckResourceHandle);
@@ -1003,7 +1004,7 @@ saLckResourceUnlock (
 	SaTimeT timeout)
 {
 	struct req_lib_lck_resourceunlock req_lib_lck_resourceunlock;
-	struct res_lib_lck_resourceunlock res_lib_lck_resourceunlock;
+	struct res_lib_lck_resourceunlockasync res_lib_lck_resourceunlockasync;
 	SaAisErrorT error;
 	struct lckLockIdInstance *lckLockIdInstance;
 	struct lckResourceInstance *lckResourceInstance;
@@ -1043,8 +1044,8 @@ saLckResourceUnlock (
 	error = saSendReceiveReply (lckLockIdInstance->response_fd, 
 		&req_lib_lck_resourceunlock,
 		sizeof (struct req_lib_lck_resourceunlock),
-		&res_lib_lck_resourceunlock,
-		sizeof (struct res_lib_lck_resourceunlock));
+		&res_lib_lck_resourceunlockasync,
+		sizeof (struct res_lib_lck_resourceunlockasync));
 
 	pthread_mutex_unlock (lckLockIdInstance->response_mutex);
 
@@ -1052,7 +1053,7 @@ saLckResourceUnlock (
 
 	saHandleDestroy (&lckLockIdHandleDatabase, lockId);
 
-	return (error == SA_AIS_OK ? res_lib_lck_resourceunlock.header.error : error);
+	return (error == SA_AIS_OK ? res_lib_lck_resourceunlockasync.header.error : error);
 }
 
 SaAisErrorT