--- innwebd/controld.cpp 2004/07/03 05:35:02 1.3 +++ innwebd/controld.cpp 2004/07/03 15:10:23 1.5 @@ -35,17 +35,24 @@ int controld::Accept(void) CString out,cmd; char temp[256]; int result; + HANDLE hThreadCurrent; try { + hThreadCurrent = GetCurrentThread(); + out.Format("200 %s ready.",App_common::GetVersion()); this->s_send(out); while(!this->thread_terminate) { + this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WAITING); + if (this->s_receive(out) == 0) //Connection closed break; out.Trim(); + this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING); + syslog << logfile::log_head << "Cmd: " << out << endl; if (sscanf(out,"%20s",temp) ==1) @@ -73,15 +80,15 @@ int controld::Accept(void) if (cmd == "BBSD") { - result = ((controld*)(this->p_ParentThread))->bbsd.begin(); + result = ((controld*)(this->GetParentThread()))->bbsd.begin(); } if (cmd == "INND") { - result = ((controld*)(this->p_ParentThread))->innd.begin(); + result = ((controld*)(this->GetParentThread()))->innd.begin(); } if (cmd == "OUTD") { - result = ((controld*)(this->p_ParentThread))->outd.begin(); + result = ((controld*)(this->GetParentThread()))->outd.begin(); } this->s_send(result == 0 ? "OK" : "Failed"); @@ -115,15 +122,15 @@ int controld::Accept(void) if (cmd == "BBSD") { - result = ((controld*)(this->p_ParentThread))->bbsd.end(); + result = ((controld*)(this->GetParentThread()))->bbsd.end(); } if (cmd == "INND") { - result = ((controld*)(this->p_ParentThread))->innd.end(); + result = ((controld*)(this->GetParentThread()))->innd.end(); } if (cmd == "OUTD") { - result = ((controld*)(this->p_ParentThread))->outd.end(); + result = ((controld*)(this->GetParentThread()))->outd.end(); } this->s_send(result == 0 ? "OK" : "Failed"); @@ -146,11 +153,11 @@ int controld::Accept(void) { this->_send("Shutting down ... ",falsse); - ((controld*)(this->p_ParentThread))->ShutdownChild(); + ((controld*)(this->GetParentThread()))->ShutdownChild(); this->s_send("OK"); - ((controld*)(this->p_ParentThread))->Shutdown(); + ((controld*)(this->GetParentThread()))->Shutdown(); break; } else @@ -164,8 +171,8 @@ int controld::Accept(void) { this->s_send("Reloading prev_list ... ",false); - ((controld*)(this->p_ParentThread))->unload_priv(); - if (((controld*)(this->p_ParentThread))->load_priv() == 0) + ((controld*)(this->GetParentThread()))->unload_priv(); + if (((controld*)(this->GetParentThread()))->load_priv() == 0) this->s_send("OK"); else this->s_send("Failed"); @@ -448,3 +455,31 @@ void controld::ShutdownChild(void) syslog << logfile::log_head << "End OUTD ... Failed" << endl; } } + +int controld::InitThreadPool(void) +{ + base* p_ParentThread; + + p_ParentThread = new controld(); + + this->SetParentThread(p_ParentThread); + this->bbsd.SetParentThread(p_ParentThread); + this->innd.SetParentThread(p_ParentThread); + this->outd.SetParentThread(p_ParentThread); + + p_ParentThread->SetThreadPool(new thread_pool(TS_MAX_THREAD)); + + if (p_ParentThread->GetThreadPool()->GetLastError() != 0) + { + syslog << logfile::log_head << "Create Thread Pool ... failed" << endl; + } + + return 0; +} + +int controld::CleanupThreadPool(void) +{ + delete(this->GetParentThread()); + + return 0; +}