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

Diff of /innwebd/base.cpp

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

Revision 1.1 by sysadm, Fri Jul 2 11:22:07 2004 UTC Revision 1.4 by sysadm, Sun Jul 4 06:45:23 2004 UTC
# Line 1  Line 1 
1  /*******************************************************/  /*******************************************************/
2  /*                                                     */  /*                                                     */
3  /*  LeafOK Innd                                        */  /*  LeafOK Innbbsd                                     */
4  /*  Copyright (C) LeafOK.com, 2003-2004                */  /*  Copyright (C) LeafOK.com, 2003-2004                */
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 21  Line 21 
21  using namespace std;  using namespace std;
22    
23  base::base(void)  base::base(void)
24  : innd_uid(0)  : p_ParentThread(NULL)
25    , p_ThreadPool(NULL)
26    , ulMainThreadId(0)
27    , innd_uid(0)
28  , isConnected(false)  , isConnected(false)
29  , running(false)  , running(false)
30  {  {
# Line 29  base::base(void) Line 32  base::base(void)
32    
33  base::~base(void)  base::~base(void)
34  {  {
35            if (this->GetThreadPool() != NULL)
36                    delete (this->GetThreadPool());
37  }  }
38    
39  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)
# Line 280  int base::bbs_post(const CString& head, Line 285  int base::bbs_post(const CString& head,
285                                                  RS.GetFieldValue("UID",dbVar,SQL_C_SLONG);                                                  RS.GetFieldValue("UID",dbVar,SQL_C_SLONG);
286                                                  sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)"                                                  sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)"
287                                                                  " valulues(%ld,%ld,'%s',now(),'%s')",                                                                  " valulues(%ld,%ld,'%s',now(),'%s')",
288                                                                  this->innd_uid,dbVar.m_lVal,addslashes(msg_connt),ththis->hostaddr);                                                                  this->innd_uid,dbVar.m_lVal,addslashes(msg_content),this->hostaddr);
289                                                  this->Db.ExecuteSQL(sql);                                                  this->Db.ExecuteSQL(sql);
290                                          }                                          }
291                                  }                                  }
# Line 452  int base::s_receive(CString& out_str, co Line 457  int base::s_receive(CString& out_str, co
457          return total_read;          return total_read;
458  }  }
459    
 bool base::IsRunning(void)  
 {  
         return this->running;  
 }  
   
460  int base::begin(void)  int base::begin(void)
461  {  {
462          ULONG ulThreadId;          ULONG ulThreadId;
# Line 496  DWORD base::Thread(LPVOID pParam) Line 496  DWORD base::Thread(LPVOID pParam)
496          base* p;          base* p;
497    
498          syslog << logfile::log_head << "Thread started." << endl;          syslog << logfile::log_head << "Thread started." << endl;
499    
500          p = (base*)pParam;          p = (base*)pParam;
501    
502            p->ulMainThreadId = GetCurrentThreadId();
503    
504            if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0)
505            {
506                    syslog << logfile::log_head << "Register thread ... Failed" << endl;
507            }
508            p->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING);
509    
510          p->w_call();          p->w_call();
511    
512            if (p->GetParentThread()->GetThreadPool()->RemoveThread(GetCurrentThreadId()) != 0)
513            {
514                    syslog << logfile::log_head << "Unregister thread ... Failed" << endl;
515            }
516    
517          syslog << logfile::log_head << "Thread stopped." << endl;          syslog << logfile::log_head << "Thread stopped." << endl;
518    
519          return 0;          return 0;
# Line 537  int base::Startup(void) Line 553  int base::Startup(void)
553  {  {
554          return 0;          return 0;
555  }  }
556    
557    bool base::IsThreadActive(void)
558    {
559            bool bIsActive = false;
560    
561            switch (this->GetParentThread()->GetThreadPool()->GetThreadStatus(this->ulMainThreadId))
562            {
563            case thread_pool::S_WAITING:
564            case thread_pool::S_WORKING:
565                    bIsActive = true;
566                    break;
567            default:
568                    bIsActive = false;
569            }
570    
571            return bIsActive;
572    }


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

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