diff --git a/src/cm_client/cm_client.cpp b/src/cm_client/cm_client.cpp index d47c0cfe9ba383680a1689c57b70486b8018ac91..fac3b2c173e25603c97cfb0b78f402c43714529a 100644 --- a/src/cm_client/cm_client.cpp +++ b/src/cm_client/cm_client.cpp @@ -107,7 +107,7 @@ void SendMsgApi(char *msgPtr, size_t msgLen) { MsgPackage msg = {msgPtr, msgLen}; (void)pthread_mutex_lock(&g_sendMsg->lock); - g_sendMsg->sendQueue.push(msg); + g_sendMsg->sendQueue.push_back(msg); (void)pthread_mutex_unlock(&g_sendMsg->lock); (void)pthread_cond_signal(&g_sendMsg->cond); } @@ -169,7 +169,7 @@ static void ConnectClose() (void)pthread_mutex_lock(&g_sendMsg->lock); while (!g_sendMsg->sendQueue.empty()) { free(g_sendMsg->sendQueue.front().msgPtr); - g_sendMsg->sendQueue.pop(); + g_sendMsg->sendQueue.pop_front(); } (void)pthread_mutex_unlock(&g_sendMsg->lock); @@ -314,7 +314,7 @@ void SendOneMsgToAgent() return; } MsgPackage msgPkg = g_sendMsg->sendQueue.front(); - g_sendMsg->sendQueue.pop(); + g_sendMsg->sendQueue.pop_front(); (void)pthread_mutex_unlock(&g_sendMsg->lock); if (msgPkg.msgPtr == NULL) { @@ -597,9 +597,7 @@ static void InitGlobalVariable(const char *resName) (void)pthread_mutex_init(&g_initFlag->lock, NULL); InitPthreadCondMonotonic(&g_initFlag->cond); - while (!g_sendMsg->sendQueue.empty()) { - g_sendMsg->sendQueue.pop(); - } + g_sendMsg->sendQueue.clear(); (void)pthread_mutex_init(&g_sendMsg->lock, NULL); InitPthreadCondMonotonic(&g_sendMsg->cond); diff --git a/src/cm_common/cm_misc_res.cpp b/src/cm_common/cm_misc_res.cpp index 3b8c064f8420a9ccdeffa8d2e5f1afa6baafc9f2..a6abdb466c5d8e74bc730662112433e25e90d6f9 100644 --- a/src/cm_common/cm_misc_res.cpp +++ b/src/cm_common/cm_misc_res.cpp @@ -54,7 +54,7 @@ typedef struct ResConfDefaultSt { const char *defValue; } ResConfDefault; -static ResConfRange g_resConfRange[] = { +static const ResConfRange g_resConfRange[] = { {"check_interval", 1, 2147483647}, {"time_out", 1, 2147483647}, {"abnormal_timeout", 0, 2147483647}, diff --git a/src/cm_ctl/ctl_res.cpp b/src/cm_ctl/ctl_res.cpp index df74abe5bdefa5ff39c7a0974a6ad51393d798eb..582ccd861e0441f3017ad7157b5cad9bab4b8005 100644 --- a/src/cm_ctl/ctl_res.cpp +++ b/src/cm_ctl/ctl_res.cpp @@ -513,7 +513,6 @@ cJSON *GetCurResInArray(cJSON *resArray, const char *resName, const ResOption *r cJSON *resObj; const uint32 maxResCnt = CM_MAX_RES_COUNT + CM_MAX_VIP_COUNT; - //char resName[maxResCnt][CM_MAX_RES_NAME]; g_resCount = 0; int32 resIndex = -1; int32 arraySize = cJSON_GetArraySize(resArray); @@ -523,8 +522,8 @@ cJSON *GetCurResInArray(cJSON *resArray, const char *resName, const ResOption *r continue; } const char* tmpResName; - if(CheckResName(resObj, g_resNames, maxResCnt, &g_resCount, &tmpResName) != CM_SUCCESS) { - write_runlog(ERROR, "%s%s Res(%s) configure contains some error, check first.\n", GetResOperStr(resCtx->mode), + if (CheckResName(resObj, g_resNames, maxResCnt, &g_resCount, &tmpResName) != CM_SUCCESS) { + write_runlog(ERROR, "%s%s Res(%s) configure contains some error.\n", GetResOperStr(resCtx->mode), GetInstOperStr(resCtx->inst.mode), resName); return NULL; } @@ -970,12 +969,12 @@ static status_t EditStringToJson( (void)cJSON_AddStringToObject(root, key, value); } else { uint32 index = 0; - if (cm_str_equal(key, RES_NAME) && !CheckResNameForEdit(value)){ + if (cm_str_equal(key, RES_NAME) && !CheckResNameForEdit(value)) { write_runlog(ERROR, "%s%s Res(%s) fails to edit new name to json.\n", GetResOperStr(resCtx->mode), GetInstOperStr(resCtx->inst.mode), resCtx->resName); return CM_ERROR; } - if (cm_str_equal(key, RESOURCE_TYPE) && !CompareResType(value, &index)){ + if (cm_str_equal(key, RESOURCE_TYPE) && !CompareResType(value, &index)) { write_runlog(ERROR, "%s%s Res(%s) fails to edit new resource_type to json.\n", GetResOperStr(resCtx->mode), GetInstOperStr(resCtx->inst.mode), resCtx->resName); return CM_ERROR; @@ -1210,7 +1209,7 @@ static status_t EditObjectToJson( } return CM_SUCCESS; } - if(IsKeyInRestrictList(key) && (!IsValueNumber(value) || !IsResConfValid(key, (const int)CmAtol(value, -1)))) { + if (IsKeyInRestrictList(key) && (!IsValueNumber(value) || !IsResConfValid(key, (const int)CmAtol(value, -1)))) { write_runlog(ERROR, "%s%s Res(%s) fails to set key(%s) to new value(%s) due to wrong type or out of range.\n", GetResOperStr(resCtx->mode), GetInstOperStr(resCtx->inst.mode), resCtx->resName, key, value); return CM_ERROR; diff --git a/src/include/cm/cm_client/cm_client.h b/src/include/cm/cm_client/cm_client.h index d98210f46e95a75776dffde7e43c0e28cf2ac1b1..f03e6714027db1c3a3e378d493ef810748c8ea93 100644 --- a/src/include/cm/cm_client/cm_client.h +++ b/src/include/cm/cm_client/cm_client.h @@ -24,7 +24,7 @@ #ifndef CM_CLIENT_H #define CM_CLIENT_H -#include +#include #include #include "cm/cm_msg.h" #include "cm/cm_misc_base.h" @@ -66,7 +66,7 @@ typedef struct ConnAgentSt { } ConnAgent; typedef struct SendMsgQueueSt { - std::queue sendQueue; + std::list sendQueue; pthread_mutex_t lock; pthread_cond_t cond; } SendMsgQueue;