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

Diff of /innwebd/outd.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Fri Jul 2 11:39:07 2004 UTC Revision 1.9 by sysadm, Fri Apr 11 17:14:49 2008 UTC
# Line 1  Line 1 
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    
# Line 31  int outd::work() Line 27  int outd::work()
27  {  {
28          HANDLE hThreadCurrent;          HANDLE hThreadCurrent;
29          ULONG ulThreadId;          ULONG ulThreadId;
30          nntp_active* p;          base_active* p;
31          int t_count = 0;          int t_count = 0;
32    
33          if (this->running)          if (this->running)
# Line 39  int outd::work() Line 35  int outd::work()
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 && nntp_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 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);  
48    
49                                  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))
50                                  {                          {
51                                          nntp_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) && nntp_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                                  {                                  {
# Line 74  int outd::work() Line 79  int outd::work()
79                                  {                                  {
80                                          syslog << logfile::log_head << "Terminate send thread ... Failed" << endl;                                          syslog << logfile::log_head << "Terminate send thread ... Failed" << endl;
81                                  }                                  }
82                                  nntp_active::uThreadCount--;                                  CloseHandle(hThreadCurrent);
83                          }                          }
84                            base_active::uThreadCount--;
85                  }                  }
86            }
87    
88          this->running = false;          this->running = false;
89    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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