| 21 |
using namespace std; |
using namespace std; |
| 22 |
|
|
| 23 |
base::base(void) |
base::base(void) |
| 24 |
: innd_uid(0) |
: p_ParentThread(NULL) |
| 25 |
|
, innd_uid(0) |
| 26 |
, isConnected(false) |
, isConnected(false) |
| 27 |
, running(false) |
, running(false) |
| 28 |
{ |
{ |
| 281 |
RS.GetFieldValue("UID",dbVar,SQL_C_SLONG); |
RS.GetFieldValue("UID",dbVar,SQL_C_SLONG); |
| 282 |
sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)" |
sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)" |
| 283 |
" valulues(%ld,%ld,'%s',now(),'%s')", |
" valulues(%ld,%ld,'%s',now(),'%s')", |
| 284 |
this->innd_uid,dbVar.m_lVal,addslashes(msg_connt),ththis->hostaddr); |
this->innd_uid,dbVar.m_lVal,addslashes(msg_content),this->hostaddr); |
| 285 |
this->Db.ExecuteSQL(sql); |
this->Db.ExecuteSQL(sql); |
| 286 |
} |
} |
| 287 |
} |
} |
| 453 |
return total_read; |
return total_read; |
| 454 |
} |
} |
| 455 |
|
|
|
bool base::IsRunning(void) |
|
|
{ |
|
|
return this->running; |
|
|
} |
|
|
|
|
| 456 |
int base::begin(void) |
int base::begin(void) |
| 457 |
{ |
{ |
| 458 |
ULONG ulThreadId; |
ULONG ulThreadId; |
| 489 |
|
|
| 490 |
DWORD base::Thread(LPVOID pParam) |
DWORD base::Thread(LPVOID pParam) |
| 491 |
{ |
{ |
| 492 |
|
HANDLE hThreadCurrent; |
| 493 |
base* p; |
base* p; |
| 494 |
|
|
| 495 |
syslog << logfile::log_head << "Thread started." << endl; |
syslog << logfile::log_head << "Thread started." << endl; |
| 496 |
|
|
| 497 |
p = (base*)pParam; |
p = (base*)pParam; |
| 498 |
|
hThreadCurrent = GetCurrentThread(); |
| 499 |
|
|
| 500 |
|
if (p->GetParentThread()->GetThreadPool()->AddThread(hThreadCurrent, CLOCKS_PER_SEC * 30) != 0) |
| 501 |
|
{ |
| 502 |
|
syslog << logfile::log_head << "Register thread ... Failed" << endl; |
| 503 |
|
} |
| 504 |
|
p->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING); |
| 505 |
|
|
| 506 |
p->w_call(); |
p->w_call(); |
| 507 |
|
|
| 508 |
|
if (p->GetParentThread()->GetThreadPool()->RemoveThread(hThreadCurrent) != 0) |
| 509 |
|
{ |
| 510 |
|
syslog << logfile::log_head << "Unregister thread ... Failed" << endl; |
| 511 |
|
} |
| 512 |
|
|
| 513 |
syslog << logfile::log_head << "Thread stopped." << endl; |
syslog << logfile::log_head << "Thread stopped." << endl; |
| 514 |
|
|
| 515 |
return 0; |
return 0; |