Browse Source

change driver_grpc_server. Because dbus message not process, so memory leak. Add a thread to run server, a.exec() run and problem fix.

yuchuli 3 years ago
parent
commit
129e7a03b0

+ 1 - 1
src/common/modulecomm/shm/procsm.cpp

@@ -529,7 +529,7 @@ int procsm::readmsg(unsigned int index, char *str, unsigned int nMaxSize,unsigne
     if(mbAttach == false)
     {
         std::cout<<"ShareMemory Attach fail."<<std::endl;
-        return -1;
+        return -3;
     }    
     int nRtn = 0;
     mpASM->lock();

+ 1 - 0
src/common/modulecomm/shm/procsm_if.cpp

@@ -137,6 +137,7 @@ void procsm_if_readthread::run()
                 delete str;
                 if(nBufLen < 1)nBufLen = 1;
                 str = new char[nBufLen];
+  //              std::cout<<"modulecomm resize str to "<<nBufLen<<std::endl;
             }
             else
             {

+ 12 - 1
src/driver/driver_grpc_server/main.cpp

@@ -243,6 +243,8 @@ void ListenData(const char * strdata,const unsigned int nSize,const unsigned int
             char * strtem = new char[nSize];
             memcpy(strtem,strdata,nSize);
             gvectorquerymsgunit[i].mpstrmsgdata.reset(strtem);
+//            gvectorquerymsgunit[i].mpstrmsgdata = std::shared_ptr<char>(new char[nSize])  ;//.reset(strtem);
+//            mempcpy(gvectorquerymsgunit[i].mpstrmsgdata.get(),strdata,nSize);
             gvectorquerymsgunit[i].mndatasize = nSize;
    //         std::cout<<" nsize is "<<nSize<<std::endl;
             gvectorquerymsgunit[i].mbRefresh = true;
@@ -296,6 +298,14 @@ void testthread()
     }
 }
 
+
+void ServerThread()
+{
+    RunServer();
+}
+
+static std::thread * gpthreadserver;
+
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
@@ -314,7 +324,8 @@ int main(int argc, char *argv[])
 
     Init();
 
-    RunServer();
+
+    gpthreadserver = new std::thread(ServerThread);
 
     return a.exec();
 }