You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __START_PROC_KERNEL_HEADER__
  2. #define __START_PROC_KERNEL_HEADER__
  3. #include "../../lib/components/base/basicThread.h"
  4. #include "../../lib/components/base/basicSettingsProvider.h"
  5. class SP_KERNEL;
  6. #define SW_DEFAULT_TIMEOUT 60000 // 60 seconds
  7. #define SW_TIMEOUT_PERCISION 100 // 0.1 second
  8. #define INVALID_SOCKET -1
  9. typedef struct S_WATCHDOG_PROC_REC{
  10. SP_KERNEL * master;
  11. int client_socket;
  12. uint64_t timeout;
  13. bool finished;
  14. pthread_t handler;
  15. }WATCHDOG_PROC_REC;
  16. typedef std::vector<WATCHDOG_PROC_REC *> WATCHDOG_PROCS_VECTOR;
  17. class SP_KERNEL: public basicThread {
  18. protected:
  19. virtual void m_fThreadProc( void );
  20. public:
  21. static SP_KERNEL * getInstance( bool ColdStart = true );
  22. bool create(void);
  23. int getExitCause(){ return m_iExitCause; };
  24. void WaitFinish( bool force );
  25. ~SP_KERNEL();
  26. private:
  27. int m_iServerSocket;
  28. int m_iExitCause;
  29. WATCHDOG_PROCS_VECTOR m_vWPV;
  30. static SP_KERNEL * _instance;
  31. static void * sw_proc( void * );
  32. void wd_shutdown( void );
  33. SP_KERNEL();
  34. basicLogCollection * m_pLog;
  35. config_setting_t * m_pSettings;
  36. char m_pUnixSocketName[PATH_MAX];
  37. };
  38. #endif