| 1 |
/*******************************************************/ |
/*******************************************************/ |
| 2 |
/* */ |
/* */ |
| 3 |
/* LeafOK Innd */ |
/* LeafOK Innbbsd */ |
|
/* Copyright (C) LeafOK.com, 2003-2004 */ |
|
| 4 |
/* */ |
/* */ |
| 5 |
/* Programmed by Leaf */ |
/* Copyright (C) LeafOK.com, 2003-2008 */ |
|
/* E-mail:leaf@leafok.com QQ:6049044 */ |
|
| 6 |
/* */ |
/* */ |
| 7 |
/* http://bbs.leafok.com */ |
/* http://www.leafok.com */ |
|
/* http://bbs.leafok.net */ |
|
|
/* http://bbs.fenglin.info */ |
|
| 8 |
/* */ |
/* */ |
| 9 |
/*******************************************************/ |
/*******************************************************/ |
| 10 |
|
|
| 35 |
|
|
| 36 |
this->running = true; |
this->running = true; |
| 37 |
|
|
| 38 |
this->thread_terminate = false; |
this->thread_terminate = false; |
| 39 |
|
|
| 40 |
while(!this->IsShutdown()) |
while(!this->IsShutdown()) |
| 41 |
|
{ |
| 42 |
|
this->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING); |
| 43 |
|
|
| 44 |
|
if (t_count >= 600 && base_active::uThreadCount == 0) |
| 45 |
{ |
{ |
| 46 |
if (t_count >= 600 && base_active::uThreadCount == 0) |
p = new base_active(); |
| 47 |
{ |
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 base_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); |
|
| 48 |
|
|
| 49 |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId)) |
| 50 |
{ |
{ |
| 51 |
base_active::uThreadCount++; |
base_active::uThreadCount++; |
| 52 |
syslog << logfile::log_head << "Create send thread ... OK" << endl; |
CloseHandle(hThreadCurrent); |
| 53 |
} |
// syslog << logfile::log_head << "Create send thread ... OK" << endl; |
| 54 |
else |
} |
| 55 |
{ |
else |
| 56 |
delete(p); |
{ |
| 57 |
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
delete(p); |
| 58 |
} |
syslog << logfile::log_head << "Create send thread ... Failed" << endl; |
|
t_count = 0; |
|
| 59 |
} |
} |
| 60 |
Sleep(100); |
t_count = 0; |
| 61 |
t_count++; |
} |
| 62 |
|
Sleep(100); |
| 63 |
|
t_count++; |
| 64 |
|
|
| 65 |
//Terminate if timeout(5 minutes) or stopped |
//Terminate if timeout(5 minutes) or stopped |
| 66 |
if ((t_count >= 3000 || this->thread_terminate) && base_active::uThreadCount > 0) |
if ((t_count >= 3000 || this->thread_terminate) && base_active::uThreadCount > 0) |
| 67 |
|
{ |
| 68 |
|
if ((hThreadCurrent = OpenThread(THREAD_TERMINATE,FALSE,ulThreadId)) == NULL) |
| 69 |
|
{ |
| 70 |
|
syslog << logfile::log_head << "Get thread handle error in outd::work()" << endl; |
| 71 |
|
} |
| 72 |
|
else |
| 73 |
{ |
{ |
| 74 |
if (TerminateThread(hThreadCurrent,-1)) |
if (TerminateThread(hThreadCurrent,-1)) |
| 75 |
{ |
{ |
| 79 |
{ |
{ |
| 80 |
syslog << logfile::log_head << "Terminate send thread ... Failed" << endl; |
syslog << logfile::log_head << "Terminate send thread ... Failed" << endl; |
| 81 |
} |
} |
| 82 |
base_active::uThreadCount--; |
CloseHandle(hThreadCurrent); |
| 83 |
} |
} |
| 84 |
|
base_active::uThreadCount--; |
| 85 |
} |
} |
| 86 |
|
} |
| 87 |
|
|
| 88 |
this->running = false; |
this->running = false; |
| 89 |
|
|