⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libckpt.c

📁 linux集群服务器软件代码包
💻 C
📖 第 1 页 / 共 5 页
字号:
				}			}			ha_free(libClient);		}	}		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (finalParam != NULL) {		ha_free(finalParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * the invocation of this function is blocking. A new checkpoint handle is * returned upon completion. */SaErrorTsaCkptCheckpointOpen(	const SaCkptHandleT *ckptHandle,	const SaNameT *checkpointName,	const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,	SaCkptCheckpointOpenFlagsT checkpointOpenFlags,	SaTimeT timeout,	SaCkptCheckpointHandleT *checkpointHandle/*[out]*/){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqOpenParamT* openParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	time_t currentTime;	if (checkpointName == NULL) {		cl_log(LOG_ERR, 			"Null checkpoint name in saCkptCheckpointOpen");		return SA_ERR_INVALID_PARAM;	}	if (checkpointCreationAttributes == NULL) {		cl_log(LOG_ERR, 			"Null attributes in saCkptCheckpointOpen");		return SA_ERR_INVALID_PARAM;	}	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 			"Null checkpoint handle in saCkptCheckpointOpen");		return SA_ERR_INVALID_PARAM;	}		if (ckptHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptCheckpointOpen");		return SA_ERR_INVALID_PARAM;	}	time(&currentTime);	if (timeout < currentTime * 1000000000LL) {		cl_log(LOG_ERR, 		"Timeout time is earlier than the current time");		return SA_ERR_INVALID_PARAM;	}	libClient = SaCkptGetLibClientByHandle(*ckptHandle);	if (libClient == NULL) {		cl_log(LOG_ERR, 			"Invalid handle in saCkptCheckpointOpen");		return SA_ERR_INVALID_PARAM;	}	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	openParam = (SaCkptReqOpenParamT*)ha_malloc(					sizeof(SaCkptReqOpenParamT));	libCheckpoint = (SaCkptLibCheckpointT*)ha_malloc(					sizeof(SaCkptLibCheckpointT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(openParam == NULL) ||		(libCheckpoint == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointOpen");		libError = SA_ERR_NO_MEMORY;		goto openError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(openParam, 0, sizeof(SaCkptReqOpenParamT));	memset(libCheckpoint, 0, sizeof(SaCkptLibCheckpointT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_OPEN;	clientRequest->reqParamLength = sizeof(SaCkptReqOpenParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = openParam;	clientRequest->data = NULL;	memcpy(&(openParam->attr), checkpointCreationAttributes,		sizeof(SaCkptCheckpointCreationAttributesT));	openParam->openFlag = checkpointOpenFlags;	openParam->timetout = timeout;	openParam->ckptName.length = checkpointName->length;	memcpy(openParam->ckptName.value, checkpointName->value,		checkpointName->length);	ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send open request failed");		goto openError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto openError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto openError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto openError;	}	memcpy(checkpointHandle, clientResponse->data,		sizeof(SaCkptCheckpointHandleT));	/*	 * create libCheckpoint and add it to the opened checkpoint list	 */	libCheckpoint->client = libClient;	libCheckpoint->checkpointHandle = *checkpointHandle;	libCheckpoint->ckptName.length = checkpointName->length;	memcpy(libCheckpoint->ckptName.value, checkpointName->value,		checkpointName->length);	memcpy(&(libCheckpoint->createAttributes),		checkpointCreationAttributes,		sizeof(SaCkptCheckpointCreationAttributesT));	libCheckpoint->openFlag = checkpointOpenFlags;			libClient->checkpointList = g_list_append(		libClient->checkpointList,		libCheckpoint);	libCheckpointList = g_list_append(libCheckpointList,		libCheckpoint);		libError = SA_OK;openError:	if (libError != SA_OK) {		if (libCheckpoint != NULL) {			ha_free(libCheckpoint);		}	}		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (openParam != NULL) {		ha_free(openParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * open a checkpoint asynchronously */SaErrorTsaCkptCheckpointOpenAsync(	const SaCkptHandleT *ckptHandle,	SaInvocationT invocation,	const SaNameT *checkpointName,	const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,	SaCkptCheckpointOpenFlagsT checkpointOpenFlags){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqOpenAsyncParamT* openAsyncParam = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;		if (ckptHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptCheckpointOpenAsync");		return SA_ERR_INVALID_PARAM;	}	if (checkpointName == NULL) {		cl_log(LOG_ERR, 			"Null checkpoint name in saCkptCheckpointOpenAsync");		return SA_ERR_INVALID_PARAM;	}	if (checkpointCreationAttributes == NULL) {		cl_log(LOG_ERR, 			"Null attributes in saCkptCheckpointOpenAsync");		return SA_ERR_INVALID_PARAM;	}	libClient = SaCkptGetLibClientByHandle(*ckptHandle);	if (libClient == NULL) {		cl_log(LOG_ERR, 			"Invalid handle in saCkptCheckpointOpenAsync");		return SA_ERR_INVALID_PARAM;	}	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	openAsyncParam = (SaCkptReqOpenAsyncParamT*)ha_malloc(					sizeof(SaCkptReqOpenAsyncParamT));	libCheckpoint = (SaCkptLibCheckpointT*)ha_malloc(					sizeof(SaCkptLibCheckpointT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(openAsyncParam == NULL) ||		(libCheckpoint == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointOpenAsync");		libError = SA_ERR_NO_MEMORY;		goto openError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(openAsyncParam, 0, sizeof(SaCkptReqOpenAsyncParamT));	memset(libCheckpoint, 0, sizeof(SaCkptLibCheckpointT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_OPEN_ASYNC;	clientRequest->reqParamLength = sizeof(SaCkptReqOpenAsyncParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = openAsyncParam;	clientRequest->data = NULL;	memcpy(&(openAsyncParam->attr), checkpointCreationAttributes,		sizeof(SaCkptCheckpointCreationAttributesT));	openAsyncParam->openFlag = checkpointOpenFlags;	openAsyncParam->invocation= invocation;	openAsyncParam->ckptName.length = checkpointName->length;	memcpy(openAsyncParam->ckptName.value, checkpointName->value,		checkpointName->length);	ch = libClient->channel[1]; /*async channel*/	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send open request failed");		goto openError;	}	libAsyncRequestList = g_list_append(libAsyncRequestList, 		libRequest);		return SA_OK;openError:	if (libError != SA_OK) {		if (libCheckpoint != NULL) {			ha_free(libCheckpoint);		}	}		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (openAsyncParam != NULL) {		ha_free(openAsyncParam);	}	return libError; }/*  * free the resources allocated for checkpoint handle */SaErrorTsaCkptCheckpointClose(	const SaCkptCheckpointHandleT *checkpointHandle){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqCloseParamT* closeParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptCheckpointClose");		return SA_ERR_INVALID_PARAM;	}	libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	closeParam = (SaCkptReqCloseParamT*)ha_malloc(					sizeof(SaCkptReqCloseParamT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(closeParam == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointClose");		libError = SA_ERR_NO_MEMORY;		goto closeError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(closeParam, 0, sizeof(SaCkptReqCloseParamT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_CLOSE;	clientRequest->reqParamLength = sizeof(SaCkptReqCloseParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = closeParam;	clientRequest->data = NULL;	closeParam->checkpointHandle = *checkpointHandle;		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send close request failed");		goto closeError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto closeError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto closeError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto closeError;	}	libClient->checkpointList = g_list_remove(		libClient->checkpointList, libCheckpoint);	libCheckpointList = g_list_remove(		libCheckpointList, libCheckpoint);	libError = SA_OK;closeError:	if (libError == SA_OK) {		if (libCheckpoint != NULL) {			ha_free(libCheckpoint);			libCheckpoint = NULL;		}	}		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (closeParam != NULL) {		ha_free(closeParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * remove this checkpoint. */SaErrorTsaCkptCheckpointUnlink(	const SaCkptHandleT *ckptHandle,	const SaNameT *checkpointName){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqUlnkParamT* unlinkParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	if (ckptHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptCheckpointUnlink");		return SA_ERR_INVALID_PARAM;	}	if (checkpointName == NULL) {		cl_log(LOG_ERR, 			"Null checkpointname in saCkptCheckpointUnlink");		return SA_ERR_INVALID_PARAM;	}	libClient = SaCkptGetLibClientByHandle(*ckptHandle);	if (libClient == NULL) {		cl_log(LOG_ERR, 			"Invalid handle in saCkptCheckpointUnlink");		return SA_ERR_INVALID_PARAM;	}  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	unlinkParam = (SaCkptReqUlnkParamT*)ha_malloc(					sizeof(SaCkptReqUlnkParamT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(unlinkParam == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointUnlink");		libError = SA_ERR_NO_MEMORY;		goto unlinkError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(unlinkParam, 0, sizeof(SaCkptReqUlnkParamT));	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -