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


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

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