From: Maxim Mamontov Date: Tue, 2 Aug 2011 11:57:14 +0000 (+0300) Subject: Replace static void * CONFIGPROTO::Run(void *) with normal method X-Git-Tag: 2.408-alpha~51 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/0cc864dabe50dc3012380bd957241d508335e1da Replace static void * CONFIGPROTO::Run(void *) with normal method --- diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.h b/projects/stargazer/plugins/configuration/sgconfig/configproto.h index efecd121..787267e6 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.h +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.h @@ -65,7 +65,7 @@ public: int Prepare(); int Stop(); const std::string & GetStrError() const; - static void * Run(void * a); + void Run(); private: int RecvHdr(int sock); diff --git a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp index 479a1357..4c26f0d1 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp @@ -130,7 +130,7 @@ return 0; } //----------------------------------------------------------------------------- // æÕÎËÃÉÑ ÏÂÝÅÎÉÑ Ó ËÏÎÆÉÇÕÒÁÔÏÒÏÍ -void * CONFIGPROTO::Run(void * a) +void CONFIGPROTO::Run() { /* * Function Name:ReciveSendConf @@ -141,19 +141,18 @@ void * CONFIGPROTO::Run(void * a) * 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)); - int outerSocket = accept(cp->listenSocket, + int outerSocket = accept(listenSocket, (struct sockaddr*)(&outerAddr), &outerAddrLen); - if (!cp->nonstop) + if (!nonstop) { continue; } @@ -165,77 +164,77 @@ while (cp->nonstop) 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()); - if (cp->state == confHdr) + if (state == confHdr) { - if (cp->RecvHdr(outerSocket) < 0) + if (RecvHdr(outerSocket) < 0) { 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; } - if (cp->RecvLogin(outerSocket) < 0) + if (RecvLogin(outerSocket) < 0) { 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; } - if (cp->RecvLoginS(outerSocket) < 0) + if (RecvLoginS(outerSocket) < 0) { 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; } - if (cp->RecvData(outerSocket) < 0) + if (RecvData(outerSocket) < 0) { close(outerSocket); continue; } - cp->state = confHdr; + state = confHdr; } else { - if (cp->SendLoginSAnswer(outerSocket, ans_err) < 0) + if (SendLoginSAnswer(outerSocket, ans_err) < 0) { close(outerSocket); continue; } - cp->WriteLogAccessFailed(cp->adminIP); + WriteLogAccessFailed(adminIP); } } else { - cp->WriteLogAccessFailed(cp->adminIP); + WriteLogAccessFailed(adminIP); } } else { - cp->WriteLogAccessFailed(cp->adminIP); - if (cp->SendHdrAnswer(outerSocket, ans_err) < 0) + WriteLogAccessFailed(adminIP); + if (SendHdrAnswer(outerSocket, ans_err) < 0) { close(outerSocket); continue; @@ -244,12 +243,10 @@ while (cp->nonstop) } else { - cp->WriteLogAccessFailed(cp->adminIP); + WriteLogAccessFailed(adminIP); } close(outerSocket); } - -return NULL; } //----------------------------------------------------------------------------- int CONFIGPROTO::RecvHdr(int sock) diff --git a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp index 0acc6e81..19d68f98 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp @@ -142,7 +142,7 @@ void * STG_CONFIG::Run(void * d) STG_CONFIG * stgConf = (STG_CONFIG *)d; stgConf->isRunning = true; -stgConf->config.Run(&stgConf->config); +stgConf->config.Run(); stgConf->isRunning = false; return NULL;