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.

101 lines
2.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
Kernel loop: move long blocking work out of it Every pass of the mojo kernel loop ran these synchronously; each could stall the loop (and get la_mojo killed by the watchdog): - Report cleanup (validateReports -> deleteReportDate): deleteRDFDir ran "rm -f -R <whole day>" (seconds to minutes on an SD card), daily or every second while the disk is above preserve_empty. The day is now deleted in a background thread (one at a time; calls during it return false). ~sqliteDBC waits for a running deletion (max 60 s). - MediaMTX (validateService -> restart): "systemctl restart" waited for the service to stop and start, every second if the config kept failing validation. Now "systemctl --no-block restart" (only queues the job), at most once per KH_MTX_RESTART_MIN_S (30 s). - IP UART serial provider (hardwareManager::validate -> create_SOL): a blocking connect() to an address that doesn't answer took ~2 min (SYN retries). Now non-blocking with SERIAL_SOL_CONNECT_TIMEOUT_MS (5 s), the socket mode restored afterwards, and the socket closed on failure (it leaked). - Ethernet2UART gateway nodes: hardwareManager::validate (kernel loop) validated and reconnected them again, although the node factory thread does it (deviceNode::validate). Connects of up to 5 s blocked the kernel loop, plus the wait for the node's connection lock. hardwareResource::selfValidating() (default false) is true for deviceETH2UART, and the hardware manager skips such resources. Tested: the connect timeout on its own (extracted unchanged). A peer that drops the SYN failed after 5002 ms ("Connection timed out") instead of ~2 min; refused and accepted connects are immediate; the socket is blocking again in every case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
14 hours ago
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
5 months ago
​
​
5 months ago
​
​
5 months ago
​
5 months ago
​
5 months ago
​
​
​
​
  1. #ifndef __DFSL_HARDWARE_RESOURCE_HEADER__
  2. #define __DFSL_HARDWARE_RESOURCE_HEADER__
  3. #include "../components/base/basicLogCollection.h"
  4. #include "../components/base/basicObject.h"
  5. #include "dataBinder.h"
  6. #include <arpa/inet.h>
  7. #include <linux/types.h>
  8. #include <vector>
  9. #define DBC_RESOURCE_DESC_SIZE 64
  10. typedef struct S_PARSE_RESULT_NET_INTERFACES
  11. {
  12. bool enabled;
  13. bool if_static;
  14. bool hot_plug;
  15. char address[INET6_ADDRSTRLEN];
  16. char netmask[INET6_ADDRSTRLEN];
  17. char gateway[INET6_ADDRSTRLEN];
  18. } PARSE_RESULT_NET_INTERFACES;
  19. typedef struct S_PARSE_RESULT_WIFI_SETTINGS
  20. {
  21. char SSID[64];
  22. char password[64];
  23. WIFI_ENCRIPTION encryption;
  24. bool access_point;
  25. uint8_t channel;
  26. char country_code[3];
  27. bool hiden_ssid;
  28. /* Router Settings */
  29. bool router_enabled;
  30. char router_outbond[INET6_ADDRSTRLEN];
  31. /* DHCP */
  32. bool dhcp_enabled;
  33. char range_start[INET6_ADDRSTRLEN];
  34. char range_stop[INET6_ADDRSTRLEN];
  35. char netmask[INET6_ADDRSTRLEN];
  36. char lease_period[INET6_ADDRSTRLEN];
  37. } PARSE_RESULT_WIFI_SETTINGS;
  38. class hardwareResource : public basicObject
  39. {
  40. protected:
  41. HARDWARE_PROVIDERS m_eProviderType;
  42. DBC_RESOURCE_DATA m_sResourceSettings;
  43. dataBinder * m_pDBC;
  44. basicLogCollection * m_pLog;
  45. bool m_bValid;
  46. bool m_bActive;
  47. public:
  48. hardwareResource();
  49. hardwareResource(uint32_t id, HARDWARE_PROVIDERS type = HARDWARE_PROVIDER_UNKNOWN);
  50. virtual ~hardwareResource();
  51. virtual bool create(void){
  52. return false;
  53. }
  54. virtual bool create(uint32_t id, HARDWARE_PROVIDERS type);
  55. // true: the resource is validated / reconnected by its owner (e.g. a deviceNode in the node factory
  56. // thread) - the hardware manager (kernel loop) must not do it again: a gateway connect blocked the
  57. // kernel loop for seconds, and two threads reconnected the same object
  58. virtual bool selfValidating(void){
  59. return false;
  60. }
  61. virtual bool validate(void){
  62. return m_bValid;
  63. }
  64. bool isValid(void){
  65. return m_bValid;
  66. }
  67. uint32_t getDbId(void){
  68. return m_sResourceSettings.aux_id;
  69. }
  70. RESOURCE_TYPE getHardwareType(void){
  71. return (RESOURCE_TYPE) m_sResourceSettings.type;
  72. }
  73. HARDWARE_PROVIDERS getProviderType(void){
  74. return m_eProviderType;
  75. }
  76. virtual bool activate( void ){
  77. if (!m_bActive) m_bActive = true;
  78. return m_bActive;
  79. }
  80. };
  81. typedef std::vector<hardwareResource *> VECTOR_HW_RESOURCES;
  82. #endif