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.
 watchDogDaemon: line buffer, end on client EOF, handler cleanup; la_mojo sends getpid()
watchDogDaemon (kernel.cpp)
- Client lines are assembled in a buffer. readLine() on the non-blocking
socket dropped the bytes of a line that had only partly arrived.
- EOF (client closed or crashed without "-1") ends the monitoring of that
client. Before, EOF read as "no data", and after the deadline kill(9) went
to a PID that may belong to another process by then.
- The handler record is zeroed. "finished" was uninitialized (malloc), so
the accept loop could pthread_join() a live handler and block.
- Finished handlers are joined, freed and erased correctly. erase()
inside the for loop skipped the next one, and the records were never
freed. A record whose thread could not be created is freed.
pthread_create() returns an error number, not -1.
- The bind() result is checked.
- The log says which PID is watched or stopped, and for a stall how long
ago the last update was ("WD update STALLED! (PID n, last update N ms
ago)").
kernelPrototype
- Sends getpid() as the PID to kill (was gettid(): the same value only in
the main thread).
Tested with the rebuilt daemon: the kernel scenarios as before (normal,
6 s step: not killed; hang: killed). A client that closes without "-1":
its process isn't killed later. An update split into 3 pieces, 6 times
with a 4 s deadline: understood, not killed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
10 hours ago |
|
#ifndef __START_PROC_KERNEL_HEADER__
#define __START_PROC_KERNEL_HEADER__
#include "../../lib/components/base/basicSettingsProvider.h"
#include "../../lib/components/base/basicThread.h"
class SP_KERNEL;
#define SW_DEFAULT_TIMEOUT 180000 // 180 seconds
#define SW_TIMEOUT_PERCISION 100 // 0.1 second
#define INVALID_SOCKET -1
typedef struct S_WATCHDOG_PROC_REC{ SP_KERNEL * master; int client_socket; uint64_t timeout; volatile bool finished; pthread_t handler;} WATCHDOG_PROC_REC;
typedef std::vector<WATCHDOG_PROC_REC *> WATCHDOG_PROCS_VECTOR;
class SP_KERNEL : public basicThread{ protected:
virtual void m_fThreadProc(void);
public:
static SP_KERNEL * getInstance(bool ColdStart = true); bool create(void);
int getExitCause() { return m_iExitCause; }
void WaitFinish(bool force); ~SP_KERNEL();
private:
int m_iServerSocket; int m_iExitCause; WATCHDOG_PROCS_VECTOR m_vWPV;
static SP_KERNEL * _instance; static void * sw_proc(void *); void wd_shutdown(void); SP_KERNEL(); basicLogCollection * m_pLog; config_setting_t * m_pSettings; char m_pUnixSocketName[PATH_MAX];};
#endif
|