Skip to content

Commit

Permalink
Properly remove references to events when destroying
Browse files Browse the repository at this point in the history
After destroying the check events, references to those events must be
cleared. If not, scheduling a new check event will try to destroy the
event that is still referenced, which causes a segfault.
  • Loading branch information
roelvanmeer committed Sep 6, 2022
1 parent ed9a162 commit c14644c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/naemon/checks_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ static void handle_host_check_event(struct nm_event_execution_properties *evprop
/* update the status log */
update_host_status(hst, FALSE);
}
} else if (evprop->execution_type == EVENT_EXEC_ABORTED) {
/* If the event is destroyed, remove the reference. */
hst->next_check_event = NULL;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/naemon/checks_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ static void handle_service_check_event(struct nm_event_execution_properties *evp

/* Otherwise, run the event */
run_scheduled_service_check(temp_service, options, latency);
} else if (evprop->execution_type == EVENT_EXEC_ABORTED) {
/* If the event is destroyed, remove the reference. */
temp_service->next_check_event = NULL;
}
}

Expand Down

0 comments on commit c14644c

Please sign in to comment.