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

📄 libckpt.c

📁 linux集群服务器软件代码包
💻 C
📖 第 1 页 / 共 5 页
字号:
		cl_log(LOG_ERR, 			"No initial data in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;	}	time(&currentTime);	if (sectionCreationAttributes->expirationTime < 		currentTime * 1000000000LL) {		cl_log(LOG_ERR, 		"Expiration time is earlier than the current time");		return SA_ERR_INVALID_PARAM;	}		libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	if (!(libCheckpoint->openFlag & SA_CKPT_CHECKPOINT_WRITE)) {		cl_log(LOG_ERR, 			"Checkpoint is not opened for write");		return SA_ERR_ACCESS;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));						secCrtParam = (SaCkptReqSecCrtParamT*)ha_malloc(					sizeof(SaCkptReqSecCrtParamT)	\					+sectionCreationAttributes->sectionId->idLen);	if (initialDataSize > 0) {		data = (void*)ha_malloc(initialDataSize);	}	 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(secCrtParam == NULL) ||		((initialDataSize > 0) && (data == NULL))) {		cl_log(LOG_ERR, 			"No memory in checkpoint library");		libError = SA_ERR_NO_MEMORY;		goto secCrtError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(secCrtParam, 0, sizeof(SaCkptReqSecCrtParamT)\		+sectionCreationAttributes->sectionId->idLen);	memcpy(data, initialData, initialDataSize);		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_SEC_CRT;	clientRequest->reqParamLength = sizeof(SaCkptReqSecCrtParamT) + sectionCreationAttributes->sectionId->idLen;	clientRequest->dataLength = initialDataSize;	clientRequest->reqParam = secCrtParam;	clientRequest->data = data;	secCrtParam->checkpointHandle = *checkpointHandle;	secCrtParam->expireTime = 		sectionCreationAttributes->expirationTime;	secCrtParam->sectionID.idLen = 		sectionCreationAttributes->sectionId->idLen;	memcpy(secCrtParam->sectionID.id,		sectionCreationAttributes->sectionId->id,		sectionCreationAttributes->sectionId->idLen);		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send section_create request failed");		goto secCrtError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto secCrtError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto secCrtError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto secCrtError;	}	/* return the section ID */	if (clientResponse->dataLength > 0) {		sectionId = (SaCkptSectionIdT*)clientResponse->data;		sectionCreationAttributes->sectionId->idLen = 			sectionId->idLen;		memcpy(sectionCreationAttributes->sectionId->id,			sectionId->id, sectionId->idLen);	}	libError = SA_OK;secCrtError:	if (data != NULL) {		ha_free(data);	}		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (secCrtParam != NULL) {		ha_free(secCrtParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; 	}/*  * delete the section within the checkpoint. */SaErrorTsaCkptSectionDelete(	const SaCkptCheckpointHandleT *checkpointHandle,	const SaCkptSectionIdT *sectionId){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqSecDelParamT* secDelParam = 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 saCkptSectionDelete");		return SA_ERR_INVALID_PARAM;	}	if (sectionId == NULL) {		cl_log(LOG_ERR, 			"Null section ID in saCkptSectionDelete");		return SA_ERR_INVALID_PARAM;	}	if ((sectionId->id == NULL) && (sectionId->idLen == 0)) {		cl_log(LOG_ERR, 		"Cannot delete default section in saCkptSectionDelete");		return SA_ERR_INVALID_PARAM;	}		if ((sectionId->id == NULL) ^ (sectionId->idLen == 0)) {		cl_log(LOG_ERR, 		"Mismatch id and idLen on sectionId in saCkptSectionDelete");		return SA_ERR_INVALID_PARAM;	}		if ((sectionId->idLen < 0)) {		cl_log(LOG_ERR, 		"Negative idLen in saCkptSectionDelete");		return SA_ERR_INVALID_PARAM;	}		libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	if (!(libCheckpoint->openFlag & SA_CKPT_CHECKPOINT_WRITE)) {		cl_log(LOG_ERR, 			"Checkpoint is not opened for write");		return SA_ERR_ACCESS;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	secDelParam = (SaCkptReqSecDelParamT*)ha_malloc(					sizeof(SaCkptReqSecDelParamT)	\					+ sectionId->idLen);	 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(secDelParam == NULL) ) {		cl_log(LOG_ERR, 			"No memory in checkpoint library");		libError = SA_ERR_NO_MEMORY;		goto secDelError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(secDelParam, 0, sizeof(SaCkptReqSecDelParamT)\		+ sectionId->idLen );		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_SEC_DEL;	clientRequest->reqParamLength = sizeof(SaCkptReqSecDelParamT) + sectionId->idLen;	clientRequest->dataLength = 0;	clientRequest->reqParam = secDelParam;	clientRequest->data = NULL;	secDelParam->checkpointHandle = *checkpointHandle;	secDelParam->sectionID.idLen = sectionId->idLen;	memcpy(secDelParam->sectionID.id, sectionId->id,		sectionId->idLen);		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send section_delete request failed");		goto secDelError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto secDelError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto secDelError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto secDelError;	}	libError = SA_OK;secDelError:	if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (secDelParam != NULL) {		ha_free(secDelParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/* set the section expiration time */SaErrorTsaCkptSectionExpirationTimeSet(	const SaCkptCheckpointHandleT *checkpointHandle,	const SaCkptSectionIdT* sectionId,	SaTimeT expirationTime){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqSecExpSetParamT* secExpSetParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	time_t currentTime;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 		"Null handle in saCkptSectionExpirationTimeSet");		return SA_ERR_INVALID_PARAM;	}	if (sectionId == NULL) {		cl_log(LOG_ERR, 		"Null section ID in saCkptSectionExpirationTimeSet");		return SA_ERR_INVALID_PARAM;	}	if ((sectionId->id == NULL) && (sectionId->idLen == 0)) {		cl_log(LOG_ERR, 			"Default section can not expire");		return SA_ERR_INVALID_PARAM;	}		if ((sectionId->id == NULL) ^ (sectionId->idLen == 0)) {		cl_log(LOG_ERR, 		"Mismatch id and idLen on sectionId in saCkptSectionExpirationTimeSet");		return SA_ERR_INVALID_PARAM;	}		if ((sectionId->idLen < 0)) {		cl_log(LOG_ERR, 		"Negative idLen in saCkptSectionExpirationTimeSet");		return SA_ERR_INVALID_PARAM;	}	time(&currentTime);	if (expirationTime < currentTime * 1000000000LL) {		cl_log(LOG_ERR, 		"Expiration time is earlier than the current time");		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));	secExpSetParam = (SaCkptReqSecExpSetParamT*)ha_malloc(					sizeof(SaCkptReqSecExpSetParamT)	\					+ sectionId->idLen);	 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(secExpSetParam == NULL) ) {		cl_log(LOG_ERR, 			"No memory in checkpoint library");		libError = SA_ERR_NO_MEMORY;		goto secExpSetError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(secExpSetParam, 0, sizeof(SaCkptReqSecExpSetParamT)	\		+ sectionId->idLen);		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_SEC_EXP_SET;	clientRequest->reqParamLength = sizeof(SaCkptReqSecExpSetParamT) + sectionId->idLen;	clientRequest->dataLength = 0;	clientRequest->reqParam = secExpSetParam;	clientRequest->data = NULL;	secExpSetParam->checkpointHandle = *checkpointHandle;	secExpSetParam->sectionID.idLen = sectionId->idLen;	memcpy(secExpSetParam->sectionID.id, sectionId->id,		sectionId->idLen);	secExpSetParam->expireTime = expirationTime;		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send section_expiration_set request failed");		goto secExpSetError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto secExpSetError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto secExpSetError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto secExpSetError;	}	libError = SA_OK;secExpSetError:	if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (secExpSetParam != NULL) {		ha_free(secExpSetParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * initialize the section interator */SaErrorTsaCkptSectionIteratorInitialize(	const SaCkptCheckpointHandleT *checkpointHandle,	SaCkptSectionsChosenT sectionsChosen,	SaTimeT expirationTime,	SaCkptSectionIteratorT *sectionIterator/*[out]*/){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqSecQueryParamT* secQueryParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;	IPC_Channel* ch = NULL;	GList* sectionList = NULL;	SaCkptSectionDescriptorT* sectionDescriptor = NULL;	int sectionNumber = 0;	int i = 0;	char * p = NULL;	SaErrorT libError = SA_OK;	time_t currentTime;	if (libIteratorHash == NULL) {		cl_log(LOG_ERR, 			"Library is not initialized");		return SA_ERR_INIT;	}		if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptSectionIteratorInitialize");		return SA_ERR_INVALID_PARAM;	}	if (sectionIterator == NULL) {		cl_log(LOG_ERR, 		"Null sectionIterator in saCkptSectionIteratorInitialize");		return SA_ERR_INVALID_PARAM;	}	time(&currentTime);	if ((expirationTime < currentTime * 1000000000LL) && 		(sectionsChosen != SA_CKPT_SECTIONS_FOREVER) &&		(sectionsChosen != SA_CKPT_SECTIONS_ANY) &&		(sectionsChosen != SA_CKPT_SECTION_CORRUPTED)){		cl_log(LOG_ERR, 		"Expiration time is earlier than the current time");		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(

⌨️ 快捷键说明

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