| 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 */ |
| 31 |
{ |
{ |
| 32 |
HANDLE hThreadCurrent; |
HANDLE hThreadCurrent; |
| 33 |
ULONG ulThreadId; |
ULONG ulThreadId; |
| 34 |
nntp_active* p; |
base_active* p; |
| 35 |
int t_count = 0; |
int t_count = 0; |
| 36 |
|
|
| 37 |
if (this->running) |
if (this->running) |
| 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 |
if (t_count >= 600 && nntp_active::uThreadCount == 0) |
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); |
|
p = new nntp_active(); |
|
|
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 (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)nntp_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
| 54 |
{ |
{ |
| 55 |
nntp_active::uThreadCount++; |
base_active::uThreadCount++; |
| 56 |
syslog << logfile::log_head << "Create send thread ... OK" << endl; |
CloseHandle(hThreadCurrent); |
| 57 |
} |
syslog << logfile::log_head << "Create send thread ... OK" << endl; |
| 58 |
else |
} |
| 59 |
{ |
else |
| 60 |
delete(p); |
{ |
| 61 |
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
delete(p); |
| 62 |
} |
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
|
t_count = 0; |
|
| 63 |
} |
} |
| 64 |
Sleep(100); |
t_count = 0; |
| 65 |
t_count++; |
} |
| 66 |
|
Sleep(100); |
| 67 |
|
t_count++; |
| 68 |
|
|
| 69 |
//Terminate if timeout(5 minutes) or stopped |
//Terminate if timeout(5 minutes) or stopped |
| 70 |
if ((t_count >= 3000 || this->thread_terminate) && nntp_active::uThreadCount > 0) |
if ((t_count >= 3000 || this->thread_terminate) && base_active::uThreadCount > 0) |
| 71 |
|
{ |
| 72 |
|
if (TerminateThread(hThreadCurrent,-1)) |
| 73 |
|
{ |
| 74 |
|
syslog << logfile::log_head << "Terminate send thread ... OK" << endl; |
| 75 |
|
} |
| 76 |
|
else |
| 77 |
{ |
{ |
| 78 |
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; |
|
|
} |
|
|
nntp_active::uThreadCount--; |
|
| 79 |
} |
} |
| 80 |
|
base_active::uThreadCount--; |
| 81 |
} |
} |
| 82 |
|
} |
| 83 |
|
|
| 84 |
this->running = false; |
this->running = false; |
| 85 |
|
|