Browse Source

Z991239-6348 #comment feat: 日志错误修复

陈纪林80310970 4 months ago
parent
commit
9b2db0f7ac
1 changed files with 6 additions and 5 deletions
  1. 6 5
      Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

+ 6 - 5
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -5165,23 +5165,24 @@ void ResourceWatcherFSM::GetSystemProccess()
     CSimpleStringA endStr = ",";
     CSimpleStringA totalProcStr = "{";
 
-    int uploadTime = 0;
-    auto last_it = std::prev(processName.end());
+    int uploadTime = 0, procNo = 0;
+    int size = processName.size();
     unordered_map<int, CSimpleStringA>::iterator it;
     for (it = processName.begin(); it != processName.end(); ++it)
     {
+        procNo++;
         //"pid1":"name1"
         curProcStr = CSimpleStringA("\"") + to_string(it->first).c_str() + "\":\"" + it->second + "\"";
         len = totalProcStr.GetLength() + curProcStr.GetLength();
-        if (len > 1000 || it == last_it)
+        if (len > 1000 || procNo == size)
         {
             endStr = "}";
             uploadTime++;
-            if (it == last_it)
+            if (procNo == size)
             {
                 totalProcStr = totalProcStr + curProcStr + endStr;
                 DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetSystemProccess")(totalProcStr.GetData());
-                totalProcStr = "{";
+                break;
             }
             else
             {