Kaynağa Gözat

defect 592
If ActiveReplicaSet is called, the correct return values are not
returned, causing failures in the saf test suite.

(Logical change 1.198)


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

Steven Dake 20 yıl önce
ebeveyn
işleme
d128af9396
3 değiştirilmiş dosya ile 36 ekleme ve 8 silme
  1. 21 1
      exec/ckpt.c
  2. 3 2
      include/ipc_ckpt.h
  3. 12 5
      lib/ckpt.c

+ 21 - 1
exec/ckpt.c

@@ -215,7 +215,7 @@ struct libais_handler ckpt_libais_handlers[] =
 	{ /* 5 */
 		.libais_handler_fn	= message_handler_req_lib_ckpt_activereplicaset,
 		.response_size		= sizeof (struct res_lib_ckpt_activereplicaset),
-		.response_id		= MESSAGE_RES_CKPT_CHECKPOINT_ACTIVEREPLICASET,
+		.response_id		= MESSAGE_RES_CKPT_ACTIVEREPLICASET,
 		.flow_control		= FLOW_CONTROL_NOT_REQUIRED
 	},
 	{ /* 6 */
@@ -2315,6 +2315,26 @@ static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct c
 
 static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message)
 {
+	struct req_lib_ckpt_activereplicaset *req_lib_ckpt_activereplicaset = (struct req_lib_ckpt_activereplicaset *)message;
+	struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset;
+	struct saCkptCheckpoint *checkpoint;
+	SaAisErrorT error = SA_AIS_OK;
+
+	checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_activereplicaset->checkpointName);
+
+	/*
+	 * Make sure checkpoint is collocated and async update option
+	 */
+	if (((checkpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) ||
+		(checkpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
+		error = SA_AIS_ERR_BAD_OPERATION;
+	}
+	res_lib_ckpt_activereplicaset.header.size = sizeof (struct res_lib_ckpt_activereplicaset);
+	res_lib_ckpt_activereplicaset.header.id = MESSAGE_RES_CKPT_ACTIVEREPLICASET;
+	res_lib_ckpt_activereplicaset.header.error = error;
+
+	libais_send_response (conn_info, &res_lib_ckpt_activereplicaset,
+		sizeof (struct res_lib_ckpt_activereplicaset));
 	return (0);
 }
 

+ 3 - 2
include/ipc_ckpt.h

@@ -46,7 +46,7 @@ enum req_lib_ckpt_checkpoint_types {
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTCLOSE = 2,
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK = 3,
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET = 4,
-	MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVEREPLICASET = 5,
+	MESSAGE_REQ_CKPT_ACTIVEREPLICASET = 5,
 	MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET = 6,
 	MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE = 7,
 	MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE = 8,
@@ -66,7 +66,7 @@ enum res_lib_ckpt_checkpoint_types {
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE = 2,
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK = 3,
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET = 4,
-	MESSAGE_RES_CKPT_CHECKPOINT_ACTIVEREPLICASET = 5,
+	MESSAGE_RES_CKPT_ACTIVEREPLICASET = 5,
 	MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET = 6,
 	MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE = 7,
 	MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE = 8,
@@ -168,6 +168,7 @@ struct res_lib_ckpt_checkpointretentiondurationset {
 
 struct req_lib_ckpt_activereplicaset {
 	struct req_header header;
+	SaNameT checkpointName;
 };
 
 struct res_lib_ckpt_activereplicaset {

+ 12 - 5
lib/ckpt.c

@@ -705,18 +705,25 @@ saCkptActiveReplicaSet (
 	error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
 		 (void *)&ckptCheckpointInstance);
 	if (error != SA_AIS_OK) {
-		goto error_exit;
+		goto error_noput;
+	}
+
+	if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
+		error = SA_AIS_ERR_ACCESS;
+		goto error_put;
 	}
 
 	req_lib_ckpt_activereplicaset.header.size = sizeof (struct req_lib_ckpt_activereplicaset);
-	req_lib_ckpt_activereplicaset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVEREPLICASET;
+	req_lib_ckpt_activereplicaset.header.id = MESSAGE_REQ_CKPT_ACTIVEREPLICASET;
+	memcpy (&req_lib_ckpt_activereplicaset.checkpointName,
+		&ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
 
 	pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
 
 	error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_activereplicaset,
 		sizeof (struct req_lib_ckpt_activereplicaset), MSG_NOSIGNAL);
 	if (error != SA_AIS_OK) {
-		goto error_exit;
+		goto error_put;
 	}
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
@@ -726,9 +733,9 @@ saCkptActiveReplicaSet (
 
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 
+error_put:
 	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
-
-error_exit:
+error_noput:
 	return (error == SA_AIS_OK ? res_lib_ckpt_activereplicaset.header.error : error);
 }