fix: skip BEFORE_EVENT in persist hook functions to prevent crash
All three persist hook functions (job/worker/queue) were ignoring the situation argument, so they fired on both BEFORE and AFTER events. BEFORE_EVENT hooks pass different va_list layouts than AFTER_EVENT: - WORKER_JOIN BEFORE: (cluster_t*, char* name, int 0) vs AFTER: (cluster_t*, worker_t*) - JOB_NEW BEFORE: (cluster_t*, xce_job_submit_t*) vs AFTER: (cluster_t*, xlist_t*) Reading the wrong type from va_list caused a dereference crash. Fix: return 0 immediately on HOOK_BEFORE_EVENT in all three hooks.
This commit is contained in:
parent
6df3bd5906
commit
b830cecf97
1 changed files with 8 additions and 3 deletions
|
|
@ -993,7 +993,10 @@ int persist_job_hook_fun(int type, int situation, int detail,
|
|||
void* cls, va_list ap)
|
||||
{
|
||||
(void)type;
|
||||
(void)situation;
|
||||
/* Write to WAL only after the state change is complete.
|
||||
* BEFORE_EVENT has a different va_list layout and must be ignored. */
|
||||
if (situation != HOOK_AFTER_EVENT)
|
||||
return 0;
|
||||
|
||||
persist_t* p = cls;
|
||||
uint32_t wal_type = detail_to_wal_type(detail);
|
||||
|
|
@ -1065,7 +1068,8 @@ int persist_queue_hook_fun(int type, int situation, int detail,
|
|||
void* cls, va_list ap)
|
||||
{
|
||||
(void)type;
|
||||
(void)situation;
|
||||
if (situation != HOOK_AFTER_EVENT)
|
||||
return 0;
|
||||
|
||||
persist_t* p = cls;
|
||||
uint32_t wal_type = detail_to_wal_type(detail);
|
||||
|
|
@ -1096,7 +1100,8 @@ int persist_worker_hook_fun(int type, int situation, int detail,
|
|||
void* cls, va_list ap)
|
||||
{
|
||||
(void)type;
|
||||
(void)situation;
|
||||
if (situation != HOOK_AFTER_EVENT)
|
||||
return 0;
|
||||
|
||||
persist_t* p = cls;
|
||||
uint32_t wal_type = detail_to_wal_type(detail);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue