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);
.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,
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;
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 {
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 {
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;
};
struct ckptSectionIterationInstance {
int response_fd;
SaCkptCheckpointHandleT checkpointHandle;
+ SaNameT checkpointName;
struct list_head sectionIdListHead;
pthread_mutex_t response_mutex;
};
}
ckptSectionIterationInstance->response_fd = ckptCheckpointInstance->response_fd;
-
ckptSectionIterationInstance->checkpointHandle = checkpointHandle;
+ memcpy (&ckptSectionIterationInstance->checkpointName,
+ &ckptCheckpointInstance->checkpointName, sizeof (SaNameT));
pthread_mutex_init (&ckptSectionIterationInstance->response_mutex, NULL);
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
}
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