| 35 |
CString out,cmd; |
CString out,cmd; |
| 36 |
char temp[256]; |
char temp[256]; |
| 37 |
int result; |
int result; |
| 38 |
|
HANDLE hThreadCurrent; |
| 39 |
|
|
| 40 |
try |
try |
| 41 |
{ |
{ |
| 42 |
|
hThreadCurrent = GetCurrentThread(); |
| 43 |
|
|
| 44 |
out.Format("200 %s ready.",App_common::GetVersion()); |
out.Format("200 %s ready.",App_common::GetVersion()); |
| 45 |
this->s_send(out); |
this->s_send(out); |
| 46 |
while(!this->thread_terminate) |
while(!this->thread_terminate) |
| 47 |
{ |
{ |
| 48 |
|
this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WAITING); |
| 49 |
|
|
| 50 |
if (this->s_receive(out) == 0) //Connection closed |
if (this->s_receive(out) == 0) //Connection closed |
| 51 |
break; |
break; |
| 52 |
out.Trim(); |
out.Trim(); |
| 53 |
|
|
| 54 |
|
this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING); |
| 55 |
|
|
| 56 |
syslog << logfile::log_head << "Cmd: " << out << endl; |
syslog << logfile::log_head << "Cmd: " << out << endl; |
| 57 |
|
|
| 58 |
if (sscanf(out,"%20s",temp) ==1) |
if (sscanf(out,"%20s",temp) ==1) |
| 80 |
|
|
| 81 |
if (cmd == "BBSD") |
if (cmd == "BBSD") |
| 82 |
{ |
{ |
| 83 |
result = ((controld*)(this->p_ParentThread))->bbsd.begin(); |
result = ((controld*)(this->GetParentThread()))->bbsd.begin(); |
| 84 |
} |
} |
| 85 |
if (cmd == "INND") |
if (cmd == "INND") |
| 86 |
{ |
{ |
| 87 |
result = ((controld*)(this->p_ParentThread))->innd.begin(); |
result = ((controld*)(this->GetParentThread()))->innd.begin(); |
| 88 |
} |
} |
| 89 |
if (cmd == "OUTD") |
if (cmd == "OUTD") |
| 90 |
{ |
{ |
| 91 |
result = ((controld*)(this->p_ParentThread))->outd.begin(); |
result = ((controld*)(this->GetParentThread()))->outd.begin(); |
| 92 |
} |
} |
| 93 |
|
|
| 94 |
this->s_send(result == 0 ? "OK" : "Failed"); |
this->s_send(result == 0 ? "OK" : "Failed"); |
| 122 |
|
|
| 123 |
if (cmd == "BBSD") |
if (cmd == "BBSD") |
| 124 |
{ |
{ |
| 125 |
result = ((controld*)(this->p_ParentThread))->bbsd.end(); |
result = ((controld*)(this->GetParentThread()))->bbsd.end(); |
| 126 |
} |
} |
| 127 |
if (cmd == "INND") |
if (cmd == "INND") |
| 128 |
{ |
{ |
| 129 |
result = ((controld*)(this->p_ParentThread))->innd.end(); |
result = ((controld*)(this->GetParentThread()))->innd.end(); |
| 130 |
} |
} |
| 131 |
if (cmd == "OUTD") |
if (cmd == "OUTD") |
| 132 |
{ |
{ |
| 133 |
result = ((controld*)(this->p_ParentThread))->outd.end(); |
result = ((controld*)(this->GetParentThread()))->outd.end(); |
| 134 |
} |
} |
| 135 |
|
|
| 136 |
this->s_send(result == 0 ? "OK" : "Failed"); |
this->s_send(result == 0 ? "OK" : "Failed"); |
| 153 |
{ |
{ |
| 154 |
this->_send("Shutting down ... ",falsse); |
this->_send("Shutting down ... ",falsse); |
| 155 |
|
|
| 156 |
((controld*)(this->p_ParentThread))->ShutdownChild(); |
((controld*)(this->GetParentThread()))->ShutdownChild(); |
| 157 |
|
|
| 158 |
this->s_send("OK"); |
this->s_send("OK"); |
| 159 |
|
|
| 160 |
((controld*)(this->p_ParentThread))->Shutdown(); |
((controld*)(this->GetParentThread()))->Shutdown(); |
| 161 |
break; |
break; |
| 162 |
} |
} |
| 163 |
else |
else |
| 171 |
{ |
{ |
| 172 |
this->s_send("Reloading prev_list ... ",false); |
this->s_send("Reloading prev_list ... ",false); |
| 173 |
|
|
| 174 |
((controld*)(this->p_ParentThread))->unload_priv(); |
((controld*)(this->GetParentThread()))->unload_priv(); |
| 175 |
if (((controld*)(this->p_ParentThread))->load_priv() == 0) |
if (((controld*)(this->GetParentThread()))->load_priv() == 0) |
| 176 |
this->s_send("OK"); |
this->s_send("OK"); |
| 177 |
else |
else |
| 178 |
this->s_send("Failed"); |
this->s_send("Failed"); |
| 455 |
syslog << logfile::log_head << "End OUTD ... Failed" << endl; |
syslog << logfile::log_head << "End OUTD ... Failed" << endl; |
| 456 |
} |
} |
| 457 |
} |
} |
| 458 |
|
|
| 459 |
|
int controld::InitThreadPool(void) |
| 460 |
|
{ |
| 461 |
|
base* p_ParentThread; |
| 462 |
|
|
| 463 |
|
p_ParentThread = new controld(); |
| 464 |
|
|
| 465 |
|
this->SetParentThread(p_ParentThread); |
| 466 |
|
this->bbsd.SetParentThread(p_ParentThread); |
| 467 |
|
this->innd.SetParentThread(p_ParentThread); |
| 468 |
|
this->outd.SetParentThread(p_ParentThread); |
| 469 |
|
|
| 470 |
|
p_ParentThread->SetThreadPool(new thread_pool(TS_MAX_THREAD)); |
| 471 |
|
|
| 472 |
|
if (p_ParentThread->GetThreadPool()->GetLastError() != 0) |
| 473 |
|
{ |
| 474 |
|
syslog << logfile::log_head << "Create Thread Pool ... failed" << endl; |
| 475 |
|
} |
| 476 |
|
|
| 477 |
|
return 0; |
| 478 |
|
} |
| 479 |
|
|
| 480 |
|
int controld::CleanupThreadPool(void) |
| 481 |
|
{ |
| 482 |
|
delete(this->GetParentThread()); |
| 483 |
|
|
| 484 |
|
return 0; |
| 485 |
|
} |