| 1 |
/*******************************************************/ |
/*******************************************************/ |
| 2 |
/* */ |
/* */ |
| 3 |
/* LeafOK Innd */ |
/* LeafOK Innbbsd */ |
| 4 |
/* Copyright (C) LeafOK.com, 2003-2004 */ |
/* Copyright (C) LeafOK.com, 2003-2004 */ |
| 5 |
/* */ |
/* */ |
| 6 |
/* Programmed by Leaf */ |
/* Programmed by Leaf */ |
| 7 |
/* E-mail:leaf@leafok.com QQ:6049044 */ |
/* E-mail:leaflet@leafok.com QQ:6049044 */ |
| 8 |
/* */ |
/* */ |
| 9 |
/* http://bbs.leafok.com */ |
/* http://bbs.leafok.com */ |
| 10 |
/* http://bbs.leafok.net */ |
/* http://bbs.leafok.net */ |
| 39 |
|
|
| 40 |
this->running = true; |
this->running = true; |
| 41 |
|
|
| 42 |
this->thread_terminate = false; |
this->thread_terminate = false; |
| 43 |
|
|
| 44 |
while(!this->IsShutdown()) |
while(!this->IsShutdown()) |
| 45 |
|
{ |
| 46 |
|
this->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING); |
| 47 |
|
|
| 48 |
|
if (t_count >= 600 && base_active::uThreadCount == 0) |
| 49 |
{ |
{ |
| 50 |
this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING); |
p = new base_active(); |
| 51 |
|
p->configure(this->innd_id,this->innd_name,this->innd_server,this->innd_uid,this->w_address,this->w_port,this->w_conn_str); |
| 52 |
|
|
| 53 |
if (t_count >= 600 && base_active::uThreadCount == 0) |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
| 54 |
{ |
{ |
| 55 |
p = new base_active(); |
base_active::uThreadCount++; |
| 56 |
p->configure(this->innd_id,this->innd_name,this->innd_server,this->innd_uid,this->w_address,this->w_port,this->w_conn_str); |
syslog << logfile::log_head << "Create send thread ... OK" << endl; |
| 57 |
|
} |
| 58 |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
else |
| 59 |
{ |
{ |
| 60 |
base_active::uThreadCount++; |
delete(p); |
| 61 |
syslog << logfile::log_head << "Create send thread ... OK" << endl; |
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
|
} |
|
|
else |
|
|
{ |
|
|
delete(p); |
|
|
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
|
|
} |
|
|
t_count = 0; |
|
| 62 |
} |
} |
| 63 |
Sleep(100); |
t_count = 0; |
| 64 |
t_count++; |
} |
| 65 |
|
Sleep(100); |
| 66 |
|
t_count++; |
| 67 |
|
|
| 68 |
//Terminate if timeout(5 minutes) or stopped |
//Terminate if timeout(5 minutes) or stopped |
| 69 |
if ((t_count >= 3000 || this->thread_terminate) && base_active::uThreadCount > 0) |
if ((t_count >= 3000 || this->thread_terminate) && base_active::uThreadCount > 0) |
| 70 |
|
{ |
| 71 |
|
if (TerminateThread(hThreadCurrent,-1)) |
| 72 |
|
{ |
| 73 |
|
syslog << logfile::log_head << "Terminate send thread ... OK" << endl; |
| 74 |
|
} |
| 75 |
|
else |
| 76 |
{ |
{ |
| 77 |
if (TerminateThread(hThreadCurrent,-1)) |
syslog << logfile::log_head << "Terminate send thread ... Failed" << endl; |
|
{ |
|
|
syslog << logfile::log_head << "Terminate send thread ... OK" << endl; |
|
|
} |
|
|
else |
|
|
{ |
|
|
syslog << logfile::log_head << "Terminate send thread ... Failed" << endl; |
|
|
} |
|
|
base_active::uThreadCount--; |
|
| 78 |
} |
} |
| 79 |
|
base_active::uThreadCount--; |
| 80 |
} |
} |
| 81 |
|
} |
| 82 |
|
|
| 83 |
this->running = false; |
this->running = false; |
| 84 |
|
|