/[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.3 by sysadm, Sat Jul 3 15:10:23 2004 UTC Revision 1.5 by sysadm, Sun Jul 4 08:04:08 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 22  using namespace std; Line 22  using namespace std;
22    
23  base::base(void)  base::base(void)
24  : p_ParentThread(NULL)  : p_ParentThread(NULL)
25    , p_ThreadPool(NULL)
26    , ulMainThreadId(0)
27  , innd_uid(0)  , innd_uid(0)
28  , isConnected(false)  , isConnected(false)
29  , running(false)  , running(false)
# Line 30  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 288  int base::bbs_post(const CString& head, Line 292  int base::bbs_post(const CString& head,
292                                  RS.Close();                                  RS.Close();
293                          }                          }
294    
295                          sql.Format("insert delayed into innd_logfile(AID,art_id,msg_id,op) values"                          sql.Format("insert delayed into innd_log(AID,art_id,msg_id,op) values"
296                                  "(%ld,%ld,'%s','I')",                                  "(%ld,%ld,'%s','I')",
297                                  aid,art_id,addslashes(msg_id));                                  aid,art_id,addslashes(msg_id));
298                          this->Db.ExecuteSQL(sql);                          this->Db.ExecuteSQL(sql);
# Line 300  int base::bbs_post(const CString& head, Line 304  int base::bbs_post(const CString& head,
304          }          }
305          catch(CException* e)          catch(CException* e)
306          {          {
307                  syslog << logfile::log_head << "Error in bbs_post()" << endl;                  char strErrMsg[256];
308                    e->GetErrorMessage(strErrMsg,256);
309                    syslog << logfile::log_head << "Error in bbs_post() [" << strErrMsg << "]" << endl;
310                  e->Delete();                  e->Delete();
311                  return -1;                  return -1;
312          }          }
# Line 385  int base::bbs_delete(long id) Line 391  int base::bbs_delete(long id)
391                                  this->Db.ExecuteSQL(sql);                                  this->Db.ExecuteSQL(sql);
392                          }                          }
393    
394                          sql.Format("update innd_logfile set cancel=1 where AID=%ld",id);                          sql.Format("update innd_log set cancel=1 where AID=%ld",id);
395                          this->Db.ExecuteSQL(sql);                          this->Db.ExecuteSQL(sql);
396                  }                  }
397                  RS.Close();                  RS.Close();
398          }          }
399          catch(CException* e)          catch(CException* e)
400          {          {
401                  syslog << logfile::log_head << "Getting article error in bbs_delete()" << endl;                  char strErrMsg[256];
402                    e->GetErrorMessage(strErrMsg,256);
403                    syslog << logfile::log_head << "Getting article error in bbs_delete() [" << strErrMsg << "]" << endl;
404                  e->Delete();                  e->Delete();
405                  return -1;                  return -1;
406          }          }
# Line 489  int base::begin(void) Line 497  int base::begin(void)
497    
498  DWORD base::Thread(LPVOID pParam)  DWORD base::Thread(LPVOID pParam)
499  {  {
         HANDLE hThreadCurrent;  
500          base* p;          base* p;
501    
502          syslog << logfile::log_head << "Thread started." << endl;          syslog << logfile::log_head << "Thread started." << endl;
503    
504          p = (base*)pParam;          p = (base*)pParam;
         hThreadCurrent = GetCurrentThread();  
505    
506          if (p->GetParentThread()->GetThreadPool()->AddThread(hThreadCurrent, CLOCKS_PER_SEC * 30) != 0)          p->ulMainThreadId = GetCurrentThreadId();
507    
508            if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0)
509          {          {
510                  syslog << logfile::log_head << "Register thread ... Failed" << endl;                  syslog << logfile::log_head << "Register thread ... Failed" << endl;
511          }          }
512          p->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING);          p->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING);
513    
514          p->w_call();          p->w_call();
515    
516          if (p->GetParentThread()->GetThreadPool()->RemoveThread(hThreadCurrent) != 0)          if (p->GetParentThread()->GetThreadPool()->RemoveThread(GetCurrentThreadId()) != 0)
517          {          {
518                  syslog << logfile::log_head << "Unregister thread ... Failed" << endl;                  syslog << logfile::log_head << "Unregister thread ... Failed" << endl;
519          }          }
# Line 549  int base::Startup(void) Line 557  int base::Startup(void)
557  {  {
558          return 0;          return 0;
559  }  }
560    
561    bool base::IsThreadActive(void)
562    {
563            bool bIsActive = false;
564    
565            switch (this->GetParentThread()->GetThreadPool()->GetThreadStatus(this->ulMainThreadId))
566            {
567            case thread_pool::S_WAITING:
568            case thread_pool::S_WORKING:
569                    bIsActive = true;
570                    break;
571            default:
572                    bIsActive = false;
573            }
574    
575            return bIsActive;
576    }


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

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