/[LeafOK_CVS]/innwebd/outd.cpp
ViewVC logotype

Annotation of /innwebd/outd.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Sun Jul 4 06:45:23 2004 UTC (21 years, 8 months ago) by sysadm
Branch: MAIN
Changes since 1.3: +33 -33 lines
Content type: text/x-c++src
Version 1.4.2

1 sysadm 1.1 /*******************************************************/
2     /* */
3 sysadm 1.4 /* LeafOK Innbbsd */
4 sysadm 1.1 /* Copyright (C) LeafOK.com, 2003-2004 */
5     /* */
6     /* Programmed by Leaf */
7 sysadm 1.4 /* E-mail:leaflet@leafok.com QQ:6049044 */
8 sysadm 1.1 /* */
9     /* http://bbs.leafok.com */
10     /* http://bbs.leafok.net */
11     /* http://bbs.fenglin.info */
12     /* */
13     /*******************************************************/
14    
15     #include "StdAfx.h"
16     #include ".\outd.h"
17    
18     using namespace std;
19    
20     bool outd::thread_terminate = true;
21    
22     outd::outd(void)
23     {
24     }
25    
26     outd::~outd(void)
27     {
28     }
29    
30     int outd::work()
31     {
32     HANDLE hThreadCurrent;
33     ULONG ulThreadId;
34 sysadm 1.2 base_active* p;
35 sysadm 1.1 int t_count = 0;
36    
37     if (this->running)
38     return 1;
39    
40     this->running = true;
41    
42 sysadm 1.4 this->thread_terminate = false;
43    
44     while(!this->IsShutdown())
45     {
46     this->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING);
47 sysadm 1.1
48 sysadm 1.4 if (t_count >= 600 && base_active::uThreadCount == 0)
49 sysadm 1.1 {
50 sysadm 1.4 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 sysadm 1.3
53 sysadm 1.4 if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId))
54 sysadm 1.1 {
55 sysadm 1.4 base_active::uThreadCount++;
56     syslog << logfile::log_head << "Create send thread ... OK" << endl;
57     }
58     else
59     {
60     delete(p);
61     syslog << logfile::log_head << "Create send thread ... Failed" << endl;
62     }
63     t_count = 0;
64     }
65     Sleep(100);
66     t_count++;
67 sysadm 1.1
68 sysadm 1.4 //Terminate if timeout(5 minutes) or stopped
69     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 sysadm 1.1 }
75 sysadm 1.4 else
76 sysadm 1.1 {
77 sysadm 1.4 syslog << logfile::log_head << "Terminate send thread ... Failed" << endl;
78 sysadm 1.1 }
79 sysadm 1.4 base_active::uThreadCount--;
80 sysadm 1.1 }
81 sysadm 1.4 }
82 sysadm 1.1
83     this->running = false;
84    
85     return 0;
86     }
87    
88     int outd::Shutdown(void)
89     {
90     if (this->thread_terminate)
91     return 1;
92    
93     this->thread_terminate = true;
94    
95     return 0;
96     }
97    
98     bool outd::IsShutdown(void)
99     {
100     return this->thread_terminate;
101     }
102    
103     int outd::Startup(void)
104     {
105     if (!this->thread_terminate)
106     return 1;
107    
108     this->thread_terminate = false;
109    
110     return 0;
111     }
112    
113     int outd::w_call(void)
114     {
115     this->work();
116     return 0;
117     }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1