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

defect 708
checkpoint synchronize async call not implemented


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

Steven Dake 20 лет назад
Родитель
Сommit
566e0e4b7e
4 измененных файлов с 64 добавлено и 18 удалено
  1. 26 0
      exec/ckpt.c
  2. 2 0
      include/ipc_ckpt.h
  3. 0 1
      include/saCkpt.h
  4. 36 17
      lib/ckpt.c

+ 26 - 0
exec/ckpt.c

@@ -3262,6 +3262,32 @@ 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_checkpointsynchronizeasync (struct conn_info *conn_info, void *message)
 {
 {
+	struct req_lib_ckpt_checkpointsynchronizeasync *req_lib_ckpt_checkpointsynchronizeasync = (struct req_lib_ckpt_checkpointsynchronizeasync *)message;
+	struct res_lib_ckpt_checkpointsynchronizeasync res_lib_ckpt_checkpointsynchronizeasync;
+	struct saCkptCheckpoint *checkpoint;
+
+	checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointsynchronizeasync->checkpointName);
+	if ((checkpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
+		res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_BAD_OPERATION;
+	} else 
+	if (checkpoint->active_replica_set == 1) {
+		res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_OK;
+	} else {
+		res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_NOT_EXIST;
+	}
+
+	res_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync);
+	res_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
+	res_lib_ckpt_checkpointsynchronizeasync.invocation = req_lib_ckpt_checkpointsynchronizeasync->invocation;
+
+	libais_send_response (conn_info,
+		&res_lib_ckpt_checkpointsynchronizeasync,
+		sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
+
+	libais_send_response (conn_info->conn_info_partner,
+		&res_lib_ckpt_checkpointsynchronizeasync,
+		sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
+	
 	return (0);
 	return (0);
 }
 }
 
 

+ 2 - 0
include/ipc_ckpt.h

@@ -253,11 +253,13 @@ struct res_lib_ckpt_checkpointsynchronize {
 
 
 struct req_lib_ckpt_checkpointsynchronizeasync {
 struct req_lib_ckpt_checkpointsynchronizeasync {
 	struct req_header header;
 	struct req_header header;
+	SaNameT checkpointName;
 	SaInvocationT invocation;
 	SaInvocationT invocation;
 };
 };
 
 
 struct res_lib_ckpt_checkpointsynchronizeasync {
 struct res_lib_ckpt_checkpointsynchronizeasync {
 	struct res_header header;
 	struct res_header header;
+	SaInvocationT invocation;
 };
 };
 
 
 #endif /* IPC_CKPT_H_DEFINED */
 #endif /* IPC_CKPT_H_DEFINED */

+ 0 - 1
include/saCkpt.h

@@ -256,7 +256,6 @@ saCkptCheckpointSynchronize (
 
 
 SaAisErrorT
 SaAisErrorT
 saCkptCheckpointSynchronizeAsync (
 saCkptCheckpointSynchronizeAsync (
-	SaCkptHandleT ckptHandle,
 	SaCkptCheckpointHandleT checkpointHandle,
 	SaCkptCheckpointHandleT checkpointHandle,
 	SaInvocationT invocation);
 	SaInvocationT invocation);
 
 

+ 36 - 17
lib/ckpt.c

@@ -256,6 +256,7 @@ saCkptDispatch (
 	int cont = 1; /* always continue do loop except when set to 0 */
 	int cont = 1; /* always continue do loop except when set to 0 */
 	struct message_overlay dispatch_data;
 	struct message_overlay dispatch_data;
 	struct res_lib_ckpt_checkpointopenasync *res_lib_ckpt_checkpointopenasync;
 	struct res_lib_ckpt_checkpointopenasync *res_lib_ckpt_checkpointopenasync;
+	struct res_lib_ckpt_checkpointsynchronizeasync *res_lib_ckpt_checkpointsynchronizeasync;
 	struct ckptCheckpointInstance *ckptCheckpointInstance;
 	struct ckptCheckpointInstance *ckptCheckpointInstance;
 
 
 	if (dispatchFlags != SA_DISPATCH_ONE &&
 	if (dispatchFlags != SA_DISPATCH_ONE &&
@@ -378,6 +379,16 @@ saCkptDispatch (
 					-1,
 					-1,
 					res_lib_ckpt_checkpointopenasync->header.error);
 					res_lib_ckpt_checkpointopenasync->header.error);
 			}
 			}
+		case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC:
+			if (callbacks.saCkptCheckpointSynchronizeCallback == NULL) {
+				continue;
+			}
+
+			res_lib_ckpt_checkpointsynchronizeasync = (struct res_lib_ckpt_checkpointsynchronizeasync *) &dispatch_data;
+
+			callbacks.saCkptCheckpointSynchronizeCallback(
+				res_lib_ckpt_checkpointsynchronizeasync->invocation,
+				res_lib_ckpt_checkpointsynchronizeasync->header.error);
 			break;
 			break;
 		default:
 		default:
 			/* TODO */
 			/* TODO */
@@ -1619,44 +1630,52 @@ error_put:
 
 
 SaAisErrorT
 SaAisErrorT
 saCkptCheckpointSynchronizeAsync (
 saCkptCheckpointSynchronizeAsync (
-	SaCkptHandleT ckptHandle,
 	SaCkptCheckpointHandleT checkpointHandle,
 	SaCkptCheckpointHandleT checkpointHandle,
 	SaInvocationT invocation)
 	SaInvocationT invocation)
 {
 {
-
-	return (SA_AIS_OK);
-
-/* TODO not implemented in executive
-
-	struct ckptInstance *ckptInstance;
-	struct ckptCheckpointInstance *ckptCheckpointInstance;
 	SaAisErrorT error;
 	SaAisErrorT error;
+	struct ckptCheckpointInstance *ckptCheckpointInstance;
 	struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync;
 	struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync;
+	struct res_lib_ckpt_checkpointsynchronizeasync res_lib_ckpt_checkpointsynchronizeasync;
 
 
 	error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
 	error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle,
 		(void *)&ckptCheckpointInstance);
 		(void *)&ckptCheckpointInstance);
 	if (error != SA_AIS_OK) {
 	if (error != SA_AIS_OK) {
-
 		return (error);
 		return (error);
 	}
 	}
 
 
-	req_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronizeasync);
+	if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
+		error = SA_AIS_ERR_ACCESS;
+		goto error_put;
+	}
+
+	req_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct req_lib_ckpt_checkpointsynchronizeasync); 
 	req_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
 	req_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
+	memcpy (&req_lib_ckpt_checkpointsynchronizeasync.checkpointName,
+		&ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
 	req_lib_ckpt_checkpointsynchronizeasync.invocation = invocation;
 	req_lib_ckpt_checkpointsynchronizeasync.invocation = invocation;
 
 
 	pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
 	pthread_mutex_lock (&ckptCheckpointInstance->response_mutex);
 
 
-	pthread_mutex_lock (&ckptInstance->response_mutex);
-
-	error = saSendRetry (ckptInstance->response_fd, &req_lib_ckpt_checkpointsynchronizeasync,
+	error = saSendRetry (ckptCheckpointInstance->response_fd, &req_lib_ckpt_checkpointsynchronizeasync,
 		sizeof (struct req_lib_ckpt_checkpointsynchronizeasync), MSG_NOSIGNAL);
 		sizeof (struct req_lib_ckpt_checkpointsynchronizeasync), MSG_NOSIGNAL);
 
 
-	pthread_mutex_unlock (&ckptInstance->response_mutex);
+	if (error != SA_AIS_OK) {
+		goto error_exit;
+	}
 
 
+	error = saRecvRetry (ckptCheckpointInstance->response_fd,
+		&res_lib_ckpt_checkpointsynchronizeasync,
+		sizeof (struct res_lib_ckpt_checkpointsynchronizeasync),
+		MSG_WAITALL | MSG_NOSIGNAL);
+
+error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 
 
-	saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle);
+error_put:
+	saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle);
 
 
-	return (error);
-*/
+	return (error == SA_AIS_OK ? res_lib_ckpt_checkpointsynchronizeasync.header.error : error);
+
+	return (SA_AIS_OK);
 }
 }