]> git.stg.codes - stg.git/commitdiff
Replace static void * CONFIGPROTO::Run(void *) with normal method
authorMaxim Mamontov <faust@stg.dp.ua>
Tue, 2 Aug 2011 11:57:14 +0000 (14:57 +0300)
committerMaxim Mamontov <faust@stg.dp.ua>
Tue, 2 Aug 2011 11:57:14 +0000 (14:57 +0300)
projects/stargazer/plugins/configuration/sgconfig/configproto.h
projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp
projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp

index efecd121458f8e8214e07f8a11b1be56b8f129cf..787267e674b6b58d82061c08e3e7d91308b25bca 100644 (file)
@@ -65,7 +65,7 @@ public:
     int             Prepare();
     int             Stop();
     const std::string & GetStrError() const;
     int             Prepare();
     int             Stop();
     const std::string & GetStrError() const;
-    static void *   Run(void * a);
+    void            Run();
 
 private:
     int             RecvHdr(int sock);
 
 private:
     int             RecvHdr(int sock);
index 479a135703f24edbdaff610732da870e5393e299..4c26f0d103481524bcc9166c56c8f3f2b57cf036 100644 (file)
@@ -130,7 +130,7 @@ return 0;
 }
 //-----------------------------------------------------------------------------
 // æÕÎËÃÉÑ ÏÂÝÅÎÉÑ Ó ËÏÎÆÉÇÕÒÁÔÏÒÏÍ
 }
 //-----------------------------------------------------------------------------
 // æÕÎËÃÉÑ ÏÂÝÅÎÉÑ Ó ËÏÎÆÉÇÕÒÁÔÏÒÏÍ
-void * CONFIGPROTO::Run(void * a)
+void CONFIGPROTO::Run()
 {
 /*
  * Function Name:ReciveSendConf
 {
 /*
  * Function Name:ReciveSendConf
@@ -141,19 +141,18 @@ void * CONFIGPROTO::Run(void * a)
  * Returns: ×ÏÚ×ÒÁÝÁÅÔ NULL
  */
 
  * Returns: ×ÏÚ×ÒÁÝÁÅÔ NULL
  */
 
-CONFIGPROTO * cp = (CONFIGPROTO*)a;
-cp->state = confHdr;
+state = confHdr;
 
 
-while (cp->nonstop)
+while (nonstop)
     {
     {
-    cp->state = confHdr;
+    state = confHdr;
     struct sockaddr_in outerAddr;
     socklen_t outerAddrLen(sizeof(outerAddr));
     struct sockaddr_in outerAddr;
     socklen_t outerAddrLen(sizeof(outerAddr));
-    int outerSocket = accept(cp->listenSocket,
+    int outerSocket = accept(listenSocket,
                              (struct sockaddr*)(&outerAddr),
                              &outerAddrLen);
 
                              (struct sockaddr*)(&outerAddr),
                              &outerAddrLen);
 
-    if (!cp->nonstop)
+    if (!nonstop)
         {
         continue;
         }
         {
         continue;
         }
@@ -165,77 +164,77 @@ while (cp->nonstop)
         continue;
         }
 
         continue;
         }
 
-    cp->adminIP = *(unsigned int*)&(outerAddr.sin_addr);
+    adminIP = *(unsigned int*)&(outerAddr.sin_addr);
 
     printfd(__FILE__, "Connection accepted from %s\n", inet_ntostring(outerAddr.sin_addr.s_addr).c_str());
 
 
     printfd(__FILE__, "Connection accepted from %s\n", inet_ntostring(outerAddr.sin_addr.s_addr).c_str());
 
-    if (cp->state == confHdr)
+    if (state == confHdr)
         {
         {
-        if (cp->RecvHdr(outerSocket) < 0)
+        if (RecvHdr(outerSocket) < 0)
             {
             close(outerSocket);
             continue;
             }
             {
             close(outerSocket);
             continue;
             }
-        if (cp->state == confLogin)
+        if (state == confLogin)
             {
             {
-            if (cp->SendHdrAnswer(outerSocket, ans_ok) < 0)
+            if (SendHdrAnswer(outerSocket, ans_ok) < 0)
                 {
                 close(outerSocket);
                 continue;
                 }
 
                 {
                 close(outerSocket);
                 continue;
                 }
 
-            if (cp->RecvLogin(outerSocket) < 0)
+            if (RecvLogin(outerSocket) < 0)
                 {
                 close(outerSocket);
                 continue;
                 }
 
                 {
                 close(outerSocket);
                 continue;
                 }
 
-            if (cp->state == confLoginCipher)
+            if (state == confLoginCipher)
                 {
                 {
-                if (cp->SendLoginAnswer(outerSocket, ans_ok) < 0)
+                if (SendLoginAnswer(outerSocket, ans_ok) < 0)
                     {
                     close(outerSocket);
                     continue;
                     }
                     {
                     close(outerSocket);
                     continue;
                     }
-                if (cp->RecvLoginS(outerSocket) < 0)
+                if (RecvLoginS(outerSocket) < 0)
                     {
                     close(outerSocket);
                     continue;
                     }
 
                     {
                     close(outerSocket);
                     continue;
                     }
 
-                if (cp->state == confData)
+                if (state == confData)
                     {
                     {
-                    if (cp->SendLoginSAnswer(outerSocket, ans_ok) < 0)
+                    if (SendLoginSAnswer(outerSocket, ans_ok) < 0)
                         {
                         close(outerSocket);
                         continue;
                         }
                         {
                         close(outerSocket);
                         continue;
                         }
-                    if (cp->RecvData(outerSocket) < 0)
+                    if (RecvData(outerSocket) < 0)
                         {
                         close(outerSocket);
                         continue;
                         }
                         {
                         close(outerSocket);
                         continue;
                         }
-                    cp->state = confHdr;
+                    state = confHdr;
                     }
                 else
                     {
                     }
                 else
                     {
-                    if (cp->SendLoginSAnswer(outerSocket, ans_err) < 0)
+                    if (SendLoginSAnswer(outerSocket, ans_err) < 0)
                         {
                         close(outerSocket);
                         continue;
                         }
                         {
                         close(outerSocket);
                         continue;
                         }
-                    cp->WriteLogAccessFailed(cp->adminIP);
+                    WriteLogAccessFailed(adminIP);
                     }
                 }
             else
                 {
                     }
                 }
             else
                 {
-                cp->WriteLogAccessFailed(cp->adminIP);
+                WriteLogAccessFailed(adminIP);
                 }
             }
         else
             {
                 }
             }
         else
             {
-            cp->WriteLogAccessFailed(cp->adminIP);
-            if (cp->SendHdrAnswer(outerSocket, ans_err) < 0)
+            WriteLogAccessFailed(adminIP);
+            if (SendHdrAnswer(outerSocket, ans_err) < 0)
                 {
                 close(outerSocket);
                 continue;
                 {
                 close(outerSocket);
                 continue;
@@ -244,12 +243,10 @@ while (cp->nonstop)
         }
     else
         {
         }
     else
         {
-        cp->WriteLogAccessFailed(cp->adminIP);
+        WriteLogAccessFailed(adminIP);
         }
     close(outerSocket);
     }
         }
     close(outerSocket);
     }
-
-return NULL;
 }
 //-----------------------------------------------------------------------------
 int CONFIGPROTO::RecvHdr(int sock)
 }
 //-----------------------------------------------------------------------------
 int CONFIGPROTO::RecvHdr(int sock)
index 0acc6e810bb8080141e748784ab6a984e4a8c13e..19d68f98da37c4a446f52dc7c1d599ba323ff325 100644 (file)
@@ -142,7 +142,7 @@ void * STG_CONFIG::Run(void * d)
 STG_CONFIG * stgConf = (STG_CONFIG *)d;
 stgConf->isRunning = true;
 
 STG_CONFIG * stgConf = (STG_CONFIG *)d;
 stgConf->isRunning = true;
 
-stgConf->config.Run(&stgConf->config);
+stgConf->config.Run();
 
 stgConf->isRunning = false;
 return NULL;
 
 stgConf->isRunning = false;
 return NULL;