/[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.3 by sysadm, Sat Jul 3 13:56:04 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 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                          this->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING);                          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);
48    
49                          if (t_count >= 600 && base_active::uThreadCount == 0)                          if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId))
50                          {                          {
51                                  p = new base_active();                                  base_active::uThreadCount++;
52                                  p->configure(this->innd_id,this->innd_name,this->innd_server,this->innd_uid,this->w_address,this->w_port,this->w_conn_str);                                  CloseHandle(hThreadCurrent);
53    //                              syslog << logfile::log_head << "Create send thread ... OK" << endl;
                                 if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base_active::SendThread,(LPVOID)p,0,&ulThreadId))  
                                 {  
                                         base_active::uThreadCount++;  
                                         syslog << logfile::log_head << "Create send thread ... OK" << endl;  
                                 }  
                                 else  
                                 {  
                                         delete(p);  
                                         syslog << logfile::log_head << "Create send thread ... Failed" << endl;  
                                 }  
                                 t_count = 0;  
54                          }                          }
55                          Sleep(100);                          else
56                          t_count++;                          {
57                                    delete(p);
58                                    syslog << logfile::log_head << "Create send thread ... Failed" << endl;
59                            }
60                            t_count = 0;
61                    }
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                                  {                                  {
# Line 76  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                                  base_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