]> git.proxmox.com Git - mirror_corosync.git/commitdiff
defect 750
authorSteven Dake <sdake@redhat.com>
Fri, 15 Jul 2005 16:59:13 +0000 (16:59 +0000)
committerSteven Dake <sdake@redhat.com>
Fri, 15 Jul 2005 16:59:13 +0000 (16:59 +0000)
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

exec/ckpt.c
include/ipc_ckpt.h
lib/ckpt.c

index 085f57d6eb26bd4367b6bf2d8b4afdf848f20eb5..c084d10f8393f9facfb7b1f8609fcc6229e4a8a6 100644 (file)
@@ -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;
index 7c6ea2de85def0c50fdb26e94a760d2d54a99a54..153e1400b631ec0c56845cbd1cba507ebb8a97c7 100644 (file)
@@ -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;
 };
index 9527c9a45f4729230d4ae02adc6d58d3bd9f6475..a981c94fed32eb6aba28c5d76c344fcc2037cd7a 100644 (file)
@@ -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