소스 검색

defect 750
in saCkptIterationFinalize if no active replica set, return error


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

Steven Dake 20 년 전
부모
커밋
ec394bdf18
3개의 변경된 파일85개의 추가작업 그리고 7개의 파일을 삭제
  1. 36 0
      exec/ckpt.c
  2. 13 2
      include/ipc_ckpt.h
  3. 36 5
      lib/ckpt.c

+ 36 - 0
exec/ckpt.c

@@ -149,6 +149,7 @@ static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info
 static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message);
 
 static int message_handler_req_lib_ckpt_sectioniterationinitialize (struct conn_info *conn_info, void *message);
+static int message_handler_req_lib_ckpt_sectioniterationfinalize (struct conn_info *conn_info, void *message);
 static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message);
 
 
@@ -295,6 +296,12 @@ struct libais_handler ckpt_libais_handlers[] =
 		.flow_control		= FLOW_CONTROL_NOT_REQUIRED
 	},
 	{ /* 16 */
+		.libais_handler_fn	= message_handler_req_lib_ckpt_sectioniterationfinalize,
+		.response_size		= sizeof (struct res_lib_ckpt_sectioniterationfinalize),
+		.response_id		= MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE,
+		.flow_control		= FLOW_CONTROL_NOT_REQUIRED
+	},
+	{ /* 17 */
 		.libais_handler_fn	= message_handler_req_lib_ckpt_sectioniteratornext,
 		.response_size		= sizeof (struct res_lib_ckpt_sectioniteratornext),
 		.response_id		= MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT,
@@ -3408,6 +3415,35 @@ error_exit:
 	return (0);
 }
 
+static int message_handler_req_lib_ckpt_sectioniterationfinalize (struct conn_info *conn_info, void *message)
+{
+	struct req_lib_ckpt_sectioniterationfinalize *req_lib_ckpt_sectioniterationfinalize = (struct req_lib_ckpt_sectioniterationfinalize *)message;
+	struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize;
+	struct saCkptCheckpoint *ckptCheckpoint;
+	SaErrorT error = SA_AIS_OK;
+
+	ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioniterationfinalize->checkpointName);
+	if (ckptCheckpoint == 0) {
+		error = SA_AIS_ERR_NOT_EXIST;
+		goto error_exit;
+	}
+
+	if (ckptCheckpoint->active_replica_set == 0) {
+		log_printf (LOG_LEVEL_NOTICE, "iterationfinalize: no active replica, returning error.\n");
+		error = SA_AIS_ERR_NOT_EXIST;
+		goto error_exit;
+	}
+error_exit:
+	res_lib_ckpt_sectioniterationfinalize.header.size = sizeof (struct res_lib_ckpt_sectioniterationfinalize);
+	res_lib_ckpt_sectioniterationfinalize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE;
+	res_lib_ckpt_sectioniterationfinalize.header.error = error;
+
+	libais_send_response (conn_info, &res_lib_ckpt_sectioniterationfinalize,
+		sizeof (struct res_lib_ckpt_sectioniterationfinalize));
+
+	return (0);
+}
+
 static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message)
 {
 	struct req_lib_ckpt_sectioniteratornext *req_lib_ckpt_sectioniteratornext = (struct req_lib_ckpt_sectioniteratornext *)message;

+ 13 - 2
include/ipc_ckpt.h

@@ -55,7 +55,8 @@ enum req_lib_ckpt_checkpoint_types {
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE = 13,
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC = 14,
 	MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 15,
-	MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT = 16
+	MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE = 16,
+	MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT = 17
 };
 
 enum res_lib_ckpt_checkpoint_types {
@@ -75,7 +76,8 @@ enum res_lib_ckpt_checkpoint_types {
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE = 13,
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC = 14,
 	MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 15,
-	MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT = 16
+	MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE = 16,
+	MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT = 17
 };
 
 struct req_lib_ckpt_checkpointopen {
@@ -197,6 +199,15 @@ struct res_lib_ckpt_sectioniterationinitialize {
 	struct res_header header;
 };
 
+struct req_lib_ckpt_sectioniterationfinalize {
+	struct req_header header;
+	SaNameT checkpointName;
+};
+
+struct res_lib_ckpt_sectioniterationfinalize {
+	struct res_header header;
+};
+
 struct req_lib_ckpt_sectioniteratornext {
 	struct req_header header;
 };

+ 36 - 5
lib/ckpt.c

@@ -84,6 +84,7 @@ struct ckptCheckpointInstance {
 struct ckptSectionIterationInstance {
 	int response_fd;
 	SaCkptCheckpointHandleT checkpointHandle;
+	SaNameT checkpointName;
 	struct list_head sectionIdListHead;
 	pthread_mutex_t response_mutex;
 };
@@ -1192,8 +1193,9 @@ saCkptSectionIterationInitialize (
 	}
 
 	ckptSectionIterationInstance->response_fd = ckptCheckpointInstance->response_fd;
-
 	ckptSectionIterationInstance->checkpointHandle = checkpointHandle;
+	memcpy (&ckptSectionIterationInstance->checkpointName,
+		&ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
 
 	pthread_mutex_init (&ckptSectionIterationInstance->response_mutex, NULL);
 
@@ -1332,13 +1334,38 @@ saCkptSectionIterationFinalize (
 	struct iteratorSectionIdListEntry *iteratorSectionIdListEntry;
 	struct list_head *sectionIdIterationList;
 	struct list_head *sectionIdIterationListNext;
+	struct req_lib_ckpt_sectioniterationfinalize req_lib_ckpt_sectioniterationfinalize;
+	struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize;
 
 	error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase,
 		sectionIterationHandle, (void *)&ckptSectionIterationInstance);
 	if (error != SA_AIS_OK) {
-		goto error_noput;
+		goto error_exit;
 	}
 
+	req_lib_ckpt_sectioniterationfinalize.header.size = sizeof (struct req_lib_ckpt_sectioniterationfinalize); 
+	req_lib_ckpt_sectioniterationfinalize.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE;
+	memcpy (&req_lib_ckpt_sectioniterationfinalize.checkpointName,
+		&ckptSectionIterationInstance->checkpointName, sizeof (SaNameT));
+
+	pthread_mutex_lock (&ckptSectionIterationInstance->response_mutex);
+
+	error = saSendRetry (ckptSectionIterationInstance->response_fd,
+		&req_lib_ckpt_sectioniterationfinalize,
+		sizeof (struct req_lib_ckpt_sectioniterationfinalize), MSG_NOSIGNAL);
+
+	if (error != SA_AIS_OK) {
+		goto error_put;
+	}
+
+	error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniterationfinalize,
+		sizeof (struct res_lib_ckpt_sectioniterationfinalize), MSG_WAITALL | MSG_NOSIGNAL);
+	if (error != SA_AIS_OK) {
+		goto error_put;
+	}
+
+	pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
+
 	/*
 	 * iterate list of section ids for this iterator to free the allocated memory
 	 * be careful to cache next pointer because free removes memory from use
@@ -1356,11 +1383,15 @@ saCkptSectionIterationFinalize (
 	}
 
 	saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
-
 	saHandleDestroy (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
-
-error_noput:
 	return (error);
+
+error_put:
+	pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
+
+	saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
+error_exit:
+	return (error == SA_AIS_OK ? res_lib_ckpt_sectioniterationfinalize.header.error : error);
 }
 
 SaAisErrorT