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

Annotation of /innwebd/outd.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Jul 2 11:39:07 2004 UTC (21 years, 8 months ago) by sysadm
Branch: MAIN
Content type: text/x-c++src
nntp_outd.cpp

1 sysadm 1.1 /*******************************************************/
2     /* */
3     /* LeafOK Innd */
4     /* Copyright (C) LeafOK.com, 2003-2004 */
5     /* */
6     /* Programmed by Leaf */
7     /* E-mail:leaf@leafok.com QQ:6049044 */
8     /* */
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     nntp_active* p;
35     int t_count = 0;
36    
37     if (this->running)
38     return 1;
39    
40     this->running = true;
41    
42     this->thread_terminate = false;
43    
44     while(!this->IsShutdown())
45     {
46     if (t_count >= 600 && nntp_active::uThreadCount == 0)
47     {
48     p = new nntp_active();
49     p->configure(this->innd_id,this->innd_name,this->innd_server,this->innd_uid,this->w_address,this->w_port,this->w_conn_str);
50    
51     if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)nntp_active::SendThread,(LPVOID)p,0,&ulThreadId))
52     {
53     nntp_active::uThreadCount++;
54     syslog << logfile::log_head << "Create send thread ... OK" << endl;
55     }
56     else
57     {
58     delete(p);
59     syslog << logfile::log_head << "Create send thread ... Failed" << endl;
60     }
61     t_count = 0;
62     }
63     Sleep(100);
64     t_count++;
65    
66     //Terminate if timeout(5 minutes) or stopped
67     if ((t_count >= 3000 || this->thread_terminate) && nntp_active::uThreadCount > 0)
68     {
69     if (TerminateThread(hThreadCurrent,-1))
70     {
71     syslog << logfile::log_head << "Terminate send thread ... OK" << endl;
72     }
73     else
74     {
75     syslog << logfile::log_head << "Terminate send thread ... Failed" << endl;
76     }
77     nntp_active::uThreadCount--;
78     }
79     }
80    
81     this->running = false;
82    
83     return 0;
84     }
85    
86     int outd::Shutdown(void)
87     {
88     if (this->thread_terminate)
89     return 1;
90    
91     this->thread_terminate = true;
92    
93     return 0;
94     }
95    
96     bool outd::IsShutdown(void)
97     {
98     return this->thread_terminate;
99     }
100    
101     int outd::Startup(void)
102     {
103     if (!this->thread_terminate)
104     return 1;
105    
106     this->thread_terminate = false;
107    
108     return 0;
109     }
110    
111     int outd::w_call(void)
112     {
113     this->work();
114     return 0;
115     }

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