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

defect 646 - wrong return code in checkpoint open

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@714 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 20 лет назад
Родитель
Сommit
88dea715ff
2 измененных файлов с 28 добавлено и 15 удалено
  1. 8 4
      exec/ckpt.c
  2. 20 11
      lib/ckpt.c

+ 8 - 4
exec/ckpt.c

@@ -1291,15 +1291,14 @@ static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct i
 	} else {
 	} else {
 		if (req_lib_ckpt_checkpointopen->checkpointCreationAttributesSet &&
 		if (req_lib_ckpt_checkpointopen->checkpointCreationAttributesSet &&
 			memcmp (&ckptCheckpoint->checkpointCreationAttributes,
 			memcmp (&ckptCheckpoint->checkpointCreationAttributes,
-				&req_lib_ckpt_checkpointopen->checkpointCreationAttributesSet,
-				sizeof (SaCkptCheckpointCreationAttributesT)) == 0) {
+				&req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
+				sizeof (SaCkptCheckpointCreationAttributesT)) != 0) {
 
 
 			error = SA_AIS_ERR_EXIST;
 			error = SA_AIS_ERR_EXIST;
 			goto error_exit;
 			goto error_exit;
 		}
 		}
 	}
 	}
 
 
-
 	/*
 	/*
 	 * If the checkpoint has been unlinked, it is an invalid name
 	 * If the checkpoint has been unlinked, it is an invalid name
 	 */
 	 */
@@ -1357,7 +1356,12 @@ error_exit:
 			res_lib_ckpt_checkpointopenasync.checkpointHandle = req_exec_ckpt_checkpointopen->checkpointHandle;
 			res_lib_ckpt_checkpointopenasync.checkpointHandle = req_exec_ckpt_checkpointopen->checkpointHandle;
 			res_lib_ckpt_checkpointopenasync.invocation = req_exec_ckpt_checkpointopen->invocation;
 			res_lib_ckpt_checkpointopenasync.invocation = req_exec_ckpt_checkpointopen->invocation;
 
 
-			libais_send_response (req_exec_ckpt_checkpointopen->source.conn_info->conn_info_partner,
+			libais_send_response (
+				req_exec_ckpt_checkpointopen->source.conn_info,
+				&res_lib_ckpt_checkpointopenasync,
+				sizeof (struct res_lib_ckpt_checkpointopenasync));
+			libais_send_response (
+				req_exec_ckpt_checkpointopen->source.conn_info->conn_info_partner,
 				&res_lib_ckpt_checkpointopenasync,
 				&res_lib_ckpt_checkpointopenasync,
 				sizeof (struct res_lib_ckpt_checkpointopenasync));
 				sizeof (struct res_lib_ckpt_checkpointopenasync));
 		} else {
 		} else {

+ 20 - 11
lib/ckpt.c

@@ -351,11 +351,12 @@ saCkptDispatch (
 			 * This instance get/listadd/put required so that close
 			 * This instance get/listadd/put required so that close
 			 * later has the proper list of checkpoints
 			 * later has the proper list of checkpoints
 			 */
 			 */
-			error = saHandleInstanceGet (&checkpointHandleDatabase,
-				res_lib_ckpt_checkpointopenasync->checkpointHandle,
-				(void *)&ckptCheckpointInstance);
-			assert (error == SA_AIS_OK); /* should only be valid handles here */
 			if (res_lib_ckpt_checkpointopenasync->header.error == SA_AIS_OK) {
 			if (res_lib_ckpt_checkpointopenasync->header.error == SA_AIS_OK) {
+				error = saHandleInstanceGet (&checkpointHandleDatabase,
+					res_lib_ckpt_checkpointopenasync->checkpointHandle,
+					(void *)&ckptCheckpointInstance);
+
+					assert (error == SA_AIS_OK); /* should only be valid handles here */
 				/*
 				/*
 				 * open succeeded without error
 				 * open succeeded without error
 				 */
 				 */
@@ -373,11 +374,6 @@ saCkptDispatch (
 				/*
 				/*
 				 * open failed with error
 				 * open failed with error
 				 */
 				 */
-				saHandleInstancePut (&checkpointHandleDatabase,
-					res_lib_ckpt_checkpointopenasync->checkpointHandle);
-				saHandleDestroy (&checkpointHandleDatabase,
-					res_lib_ckpt_checkpointopenasync->checkpointHandle);
-
 				callbacks.saCkptCheckpointOpenCallback(
 				callbacks.saCkptCheckpointOpenCallback(
 					res_lib_ckpt_checkpointopenasync->invocation,
 					res_lib_ckpt_checkpointopenasync->invocation,
 					-1,
 					-1,
@@ -581,6 +577,7 @@ saCkptCheckpointOpenAsync (
 	SaCkptCheckpointHandleT checkpointHandle;
 	SaCkptCheckpointHandleT checkpointHandle;
 	SaAisErrorT error;
 	SaAisErrorT error;
 	struct req_lib_ckpt_checkpointopenasync req_lib_ckpt_checkpointopenasync;
 	struct req_lib_ckpt_checkpointopenasync req_lib_ckpt_checkpointopenasync;
+	struct res_lib_ckpt_checkpointopenasync res_lib_ckpt_checkpointopenasync;
 
 
 	if ((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) && 
 	if ((checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) && 
 		checkpointCreationAttributes == NULL) {
 		checkpointCreationAttributes == NULL) {
@@ -638,6 +635,19 @@ saCkptCheckpointOpenAsync (
 	if (error != SA_AIS_OK) {
 	if (error != SA_AIS_OK) {
 		goto error_put_destroy;
 		goto error_put_destroy;
 	}
 	}
+
+	error = saRecvRetry (ckptCheckpointInstance->response_fd,
+		&res_lib_ckpt_checkpointopenasync,
+		sizeof (struct res_lib_ckpt_checkpointopenasync),
+		MSG_WAITALL | MSG_NOSIGNAL);
+	if (error != SA_AIS_OK) {
+		goto error_put_destroy;
+	}
+	
+	if (res_lib_ckpt_checkpointopenasync.header.error != SA_AIS_OK) {
+		error = res_lib_ckpt_checkpointopenasync.header.error;
+		goto error_put_destroy;
+	}
 	
 	
 	pthread_mutex_init (&ckptCheckpointInstance->response_mutex, NULL);
 	pthread_mutex_init (&ckptCheckpointInstance->response_mutex, NULL);
 
 
@@ -645,7 +655,7 @@ saCkptCheckpointOpenAsync (
 
 
 	saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
 	saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
 
 
-	return (error);
+	return (error == SA_AIS_OK ? res_lib_ckpt_checkpointopenasync.header.error : error);
 
 
 error_put_destroy:
 error_put_destroy:
 	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
 	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
@@ -872,7 +882,6 @@ saCkptCheckpointStatusGet (
 		&res_lib_ckpt_checkpointstatusget.checkpointDescriptor,
 		&res_lib_ckpt_checkpointstatusget.checkpointDescriptor,
 		sizeof (SaCkptCheckpointDescriptorT));
 		sizeof (SaCkptCheckpointDescriptorT));
 
 
-printf ("error is %d\n", res_lib_ckpt_checkpointstatusget.header.error);
 error_exit:
 error_exit:
 	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
 	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
 	return (error == SA_AIS_OK ? res_lib_ckpt_checkpointstatusget.header.error : error);
 	return (error == SA_AIS_OK ? res_lib_ckpt_checkpointstatusget.header.error : error);