| 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"); |
| 379 |
this->innd.configure(innd_id,innd_name,innd_server,innd_uid,innd_address,innd_port,conn_str); |
this->innd.configure(innd_id,innd_name,innd_server,innd_uid,innd_address,innd_port,conn_str); |
| 380 |
this->outd.configure(innd_id,innd_name,innd_server,innd_uid,innd_address,0,conn_str); |
this->outd.configure(innd_id,innd_name,innd_server,innd_uid,innd_address,0,conn_str); |
| 381 |
|
|
| 382 |
|
base* p_ParentThread; |
| 383 |
|
|
| 384 |
|
p_ParentThread = new base_active(); |
| 385 |
|
|
| 386 |
|
this->SetParentThread(p_ParentThread); |
| 387 |
|
this->bbsd.SetParentThread(p_ParentThread); |
| 388 |
|
this->innd.SetParentThread(p_ParentThread); |
| 389 |
|
this->outd.SetParentThread(p_ParentThread); |
| 390 |
|
|
| 391 |
|
p_ParentThread->SetThreadPool(new thread_pool(TS_MAX_THREAD)); |
| 392 |
|
|
| 393 |
|
if (p_ParentThread->GetThreadPool()->GetLastError() != 0) |
| 394 |
|
{ |
| 395 |
|
syslog << logfile::log_head << "Create Thread Pool ... failed" << endl; |
| 396 |
|
} |
| 397 |
|
|
| 398 |
return 0; |
return 0; |
| 399 |
} |
} |
| 400 |
|
|