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.

59 lines
1.1 KiB

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