freeeyes
(Freeeyes)
January 14, 2020, 6:12am
1
ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
Github
CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
tavisCI
Languages of the repository
C++
Only if the SonarCloud project is public, the URL
https://sonarcloud.io/dashboard?id=freeeyes
And if you need help with pull request decoration, then the URL to the PR too
https://www.travis-ci.org/freeeyes/PSS/jobs/636717303
Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
Steps to reproduce
Potential workaround
Before using sonar cloud, there was no problem. Today, when parsing gcov, it failed to compile. I queried the output of tarvisCI and this file exists.
thanks.
freeeyes
(Freeeyes)
January 14, 2020, 7:31am
2
WorkThreadAI.h.gcov The contents of the file are as follows:
-: 0:Source:../../purenessscopeserver/FrameCore/Message/WorkThreadAI.h
-: 0:Programs:41
-: 1:#ifndef _WORKTHREADAI_H
-: 2:#define _WORKTHREADAI_H
-: 3:
-: 4://实现对工作线程效率的监控
-: 5://此想法来源于Bobo的建议,如果当一个工作线程持续出现阻塞处理数据缓慢怎么办?
-: 6://杀死工作线程和增加工作线程都不是最好的办法
-: 7://最好的办法,就是找到罪魁祸首的那个数据包
-: 8://正常情况下,应该是某种数据处理引发的问题,而不能波及全部工作线程
-: 9://如果这个问题数据包在一定时间内拖累了工作线程太长时间,那么就果断采取措施
-: 10://停止此命令处理一段时间,并返回给客户端告知
-: 11://直接走短回路回应数据异常,保证其他数据包的正常数据处理
-: 12://并记录日志,或者提醒运维管理者
-: 13://这样做尽力减少因为某一个指令问题而导致的整体服务器相应效率底下的问题
-: 14://此功能,可以根据需求决定是否开启,在main.xml里面设置开关
-: 15://如果所有数据包处理都在缓慢不在此AI的管理范围之内
-: 16://PSS依旧还有最后的自我保护机制,重启工作线程
-: 17://不过既然全部数据包都超时了,应用也不可能让用户满意了
-: 18://此功能只是最大限度的保护用户体验,用户体验是服务器的衣食父母
-: 19://add by freeeyes
-: 20:
-: 21:#include "Ring.h"
-: 22:#include "define.h"
-: 23:
-: 24:const uint16 COMMAND_RETURN_BUSY = 0xffff;
-: 25:
-: 26://二进制换砖类,负责二进制的代码转换
-: 27:class CConvertBuffer
-: 28:{
-: 29:public:
-: 30: CConvertBuffer() {}
-: 31:
-: 32: int GetBufferSize(const char* pData, int nSrcLen)
-: 33: {
-: 34: char szData[3] = {'\0'};
-: 35: int nPos = 0;
-: 36: int nCurrSize = 0;
-: 37: int nConvertSize = 0;
-: 38: bool blState = false; //转换后的字符串是否有效
-: 39: bool blSrcState = true; //元字符串是否有效
-: 40: unsigned char cData;
-: 41:
-: 42: while(nPos < nSrcLen)
-: 43: {
-: 44: if(pData[nPos] == '\r' || pData[nPos] == '\n' || pData[nPos] == ' ' || nPos == nSrcLen - 1)
-: 45: {
-: 46: if(nPos == nSrcLen - 1 && nCurrSize < 2)
-: 47: {
-: 48: szData[nCurrSize++] = pData[nPos];
-: 49: }
-: 50:
-: 51: if (nCurrSize < 3)
-: 52: {
-: 53: szData[nCurrSize] = '\0';
-: 54: }
-: 55: else
-: 56: {
-: 57: blSrcState = false;
-: 58: }
-: 59:
-: 60: if(blSrcState == true)
-: 61: {
-: 62: blState = ConvertStr2char(szData, cData);
-: 63:
-: 64: if(blState == true)
-: 65: {
-: 66: nConvertSize++;
-: 67: }
-: 68: }
-: 69:
-: 70: nCurrSize = 0;
-: 71: blSrcState = true;
-: 72: nPos++;
-: 73: }
-: 74: else
-: 75: {
-: 76: if(nCurrSize < 2)
-: 77: {
-: 78: szData[nCurrSize++] = pData[nPos];
-: 79: }
-: 80: else
-: 81: {
-: 82: blSrcState = false;
-: 83: }
-: 84:
-: 85: nPos++;
-: 86: }
-: 87: }
-: 88:
-: 89: return nConvertSize;
-: 90: }
-: 91:
-: 92: bool Convertstr2charArray(const char* pData, int nSrcLen, unsigned char* pDes, int& nMaxLen)
-: 93: {
-: 94: char szData[3] = {'\0'};
-: 95: int nPos = 0;
-: 96: int nCurrSize = 0;
-: 97: int nConvertSize = 0;
-: 98: bool blState = false; //转换后的字符串是否有效
-: 99: bool blSrcState = true; //元字符串是否有效
-: 100:
-: 101: while(nPos < nSrcLen)
-: 102: {
-: 103: if(pData[nPos] == '\r' || pData[nPos] == '\n' || pData[nPos] == ' ' || nPos == nSrcLen - 1)
-: 104: {
-: 105: if(nPos == nSrcLen - 1 && nCurrSize < 2)
-: 106: {
-: 107: szData[nCurrSize++] = pData[nPos];
-: 108: }
-: 109:
-: 110: if (nCurrSize < 3)
-: 111: {
-: 112: szData[nCurrSize] = '\0';
-: 113: }
-: 114: else
-: 115: {
-: 116: blSrcState = false;
-: 117: }
-: 118:
-: 119: if(nConvertSize < nMaxLen && blSrcState == true)
-: 120: {
-: 121: blState = ConvertStr2char(szData, pDes[nConvertSize]);
-: 122:
-: 123: if(blState == true)
-: 124: {
-: 125: nConvertSize++;
-: 126: }
-: 127: }
-: 128:
-: 129: nCurrSize = 0;
-: 130: blSrcState = true;
-: 131: nPos++;
-: 132: }
-: 133: else
-: 134: {
-: 135: if(nCurrSize < 2)
-: 136: {
-: 137: szData[nCurrSize++] = pData[nPos];
-: 138: }
-: 139: else
-: 140: {
-: 141: blSrcState = false;
-: 142: }
-: 143:
-: 144: nPos++;
-: 145: }
-: 146: }
-: 147:
-: 148: nMaxLen = nConvertSize;
-: 149: return true;
-: 150: }
-: 151:private:
-: 152: bool Get_binary_Char(unsigned char cTag, unsigned char& cDes)
-: 153: {
-: 154: if(cTag >='A'&& cTag <='F')
-: 155: {
-: 156: cDes = cTag - 'A' + 10;
-: 157: return true;
-: 158: }
-: 159: else if(cTag >='a'&& cTag <='f')
-: 160: {
-: 161: cDes = cTag - 'a' + 10;
-: 162: return true;
-: 163: }
-: 164: else if(cTag >= '0'&& cTag<= '9')
-: 165: {
-: 166: cDes = cTag-'0';
-: 167: return true;
-: 168: }
-: 169: else
-: 170: {
-: 171: return false;
-: 172: }
-: 173: }
-: 174:
-: 175: bool ConvertStr2char(const char* pData, unsigned char& cData)
-: 176: {
-: 177: if(pData == NULL || strlen(pData) != 2)
-: 178: {
-: 179: return false;
-: 180: }
-: 181:
-: 182: char cFirst = pData[1];
-: 183: unsigned char cTemp = 0;
-: 184: bool blStste = Get_binary_Char(cFirst, cTemp);
-: 185:
-: 186: if(false == blStste)
-: 187: {
-: 188: return false;
-: 189: }
-: 190:
-: 191: cData = cTemp;
-: 192: char cSecond = pData[0];
-: 193: blStste = Get_binary_Char(cSecond, cTemp);
-: 194:
-: 195: if(false == blStste)
-: 196: {
-: 197: return false;
-: 198: }
-: 199:
-: 200: cTemp = cTemp << 4;
-: 201: cData = cData | cTemp;
-: 202:
-: 203: return true;
-: 204: }
-: 205:};
-: 206:
-: 207://相关参数设计
-: 208:class _WorkThreadAIInfo
-: 209:{
-: 210:public:
-: 211: uint32 m_u4ThreadID = 0; //工作线程ID
-: 212: uint8 m_u1WTAI = 0; //工作线程AI开关,0为关闭,1为打开
-: 213: uint32 m_u4DisposeTime = 0; //业务包处理超时时间
-: 214: uint32 m_u4WTCheckTime = 0; //工作线程超时包的时间范围,单位是秒
-: 215: uint32 m_u4WTTimeoutCount = 0; //工作线程超时包的单位时间内的超时次数上限
-: 216: uint32 m_u4WTStopTime = 0; //停止此命令服务的时间
-: 217:
-: 218: _WorkThreadAIInfo()
-: 219: {
-: 220: }
-: 221:};
-: 222:
-: 223://AI配置信息表
-: 224:typedef vector<_WorkThreadAIInfo> vecWorkThreadAIInfo;
-: 225:
-: 226://超时命令单元
-: 227:class _CommandTimeout
-: 228:{
-: 229:public:
-: 230: uint32 m_u4ThreadID = 0; //工作线程ID
-: 231: uint16 m_u2CommandID = 0; //超时的命令
-: 232: uint64 m_u8Second = 0; //超时当前时间,以1970年以来开始计算的秒数
-: 233: uint32 m_u4Timeout = 0; //命令执行时间,单位是毫秒
-: 234:
-: 235: _CommandTimeout()
-: 236: {
-: 237: }
-: 238:};
-: 239:
-: 240://这里用户回传相关查询信息
-: 241:typedef vector<_CommandTimeout> vecCommandTimeout;
-: 242:
3: 243:class CWorkThreadAI
-: 244:{
-: 245:public:
-: 246: CWorkThreadAI();
-: 247:
-: 248: void Close();
-: 249:
-: 250: void Init(uint8 u1AI, uint32 u4DisposeTime, uint32 u4WTCheckTime, uint32 u4WTTimeoutCount, uint32 u4WTStopTime, uint8 u1WTReturnDataType, const char* pReturnData);
-: 251:
-: 252: bool SaveTimeout(uint16 u2CommandID, uint32 u4TimeCost);
-: 253:
-: 254: char* GetReturnData();
-: 255: uint16 GetReturnDataLength();
-: 256:
-: 257: void GetAIInfo(_WorkThreadAIInfo& objWorkThreadAIInfo);
-: 258:
-: 259: void ReSet(uint8 u1AI, uint32 u4DisposeTime, uint32 u4WTCheckTime, uint32 u4WTStopTime);
-: 260:
-: 261: bool CheckCurrTimeout(uint16 u2CommandID, uint64 u8Now);
-: 262:
-: 263: void GetAllTimeout(uint32 u4ThreadID, vecCommandTimeout& objTimeout);
-: 264: void GetAllForbiden(uint32 u4ThreadID, vecCommandTimeout& objForbiden);
-: 265:
-: 266:private:
-: 267: int Do_Command_Account(uint16 u2CommandID, uint64 u8Now, uint32 u4TimeCost, bool& blRet); //统计Command的AI数据
-: 268:
-: 269: uint8 m_u1WTAI = 0; //工作线程AI开关,0为关闭,1为打开
-: 270: uint16 m_u2ReturnDataLen = 0; //返回数据体长度
-: 271: uint16 m_u4DisposeTime = 0; //业务包处理超时时间
-: 272: uint32 m_u4WTCheckTime = 0; //工作线程超时包的时间范围,单位是秒
-: 273: uint32 m_u4WTTimeoutCount = 0; //工作线程超时包的单位时间内的超时次数上限
-: 274: uint32 m_u4WTStopTime = 0; //停止此命令服务的时间
-: 275: uint8 m_u1WTReturnDataType = 0; //返回错误数据的类型,1为二进制,2为文本
-: 276: char m_szWTReturnData[MAX_BUFF_1024] = {'\0'}; //返回的数据体,最多1K
-: 277:
-: 278: //超时的命令集合
-: 279: class _CommandTime
-: 280: {
-: 281: public:
-: 282: uint16 m_u2CommandID = 0;
-: 283: CRingLink<_CommandTimeout> m_objTime;
-: 284:
-: 285: _CommandTime()
-: 286: {
-: 287: }
-: 288: };
-: 289:
-: 290: vector<_CommandTime*> m_vecCommandTime;
-: 291: vector<_CommandTimeout> m_vecCommandTimeout;
-: 292:};
-: 293:#endif
mpaladin
(Massimo Paladin)
January 14, 2020, 8:56am
4
Hi @freeeyes ,
thank you for your report, you are affected by this regression: CPP-2395 .
While waiting for a fix you can avoid such issue by changing the encoding of the source file related to the failing report to UTF-8.
freeeyes
(Freeeyes)
January 20, 2020, 9:03am
5
@mpaladin
I see that the bug status is already closed, but the sonar cloud still seems to be reporting an error. Is it still a few days before the sonar cloud is updated?
thanks help.
mpaladin
(Massimo Paladin)
January 20, 2020, 10:59am
6
Hi @freeeyes ,
you are going to have to wait for the release of SonarCFamily before deployment on SonarCloud.