--- innwebd/base.cpp 2004/07/02 11:22:07 1.1 +++ innwebd/base.cpp 2004/07/03 15:10:23 1.3 @@ -21,7 +21,8 @@ using namespace std; base::base(void) -: innd_uid(0) +: p_ParentThread(NULL) +, innd_uid(0) , isConnected(false) , running(false) { @@ -280,7 +281,7 @@ int base::bbs_post(const CString& head, RS.GetFieldValue("UID",dbVar,SQL_C_SLONG); sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)" " valulues(%ld,%ld,'%s',now(),'%s')", - this->innd_uid,dbVar.m_lVal,addslashes(msg_connt),ththis->hostaddr); + this->innd_uid,dbVar.m_lVal,addslashes(msg_content),this->hostaddr); this->Db.ExecuteSQL(sql); } } @@ -452,11 +453,6 @@ int base::s_receive(CString& out_str, co return total_read; } -bool base::IsRunning(void) -{ - return this->running; -} - int base::begin(void) { ULONG ulThreadId; @@ -493,11 +489,27 @@ int base::begin(void) DWORD base::Thread(LPVOID pParam) { + HANDLE hThreadCurrent; base* p; syslog << logfile::log_head << "Thread started." << endl; + p = (base*)pParam; + hThreadCurrent = GetCurrentThread(); + + if (p->GetParentThread()->GetThreadPool()->AddThread(hThreadCurrent, CLOCKS_PER_SEC * 30) != 0) + { + syslog << logfile::log_head << "Register thread ... Failed" << endl; + } + p->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING); + p->w_call(); + + if (p->GetParentThread()->GetThreadPool()->RemoveThread(hThreadCurrent) != 0) + { + syslog << logfile::log_head << "Unregister thread ... Failed" << endl; + } + syslog << logfile::log_head << "Thread stopped." << endl; return 0;