You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.
Created by mfriedrich on 2010-11-24 12:05:45 +00:00
Assignee: mfriedrich
Status: Resolved (closed on 2010-11-24 12:53:40 +00:00)
Target Version: 1.3
Last Update: 2010-11-24 12:53:40 +00:00 (in Redmine)
From: Andreas Ericsson
Date: Wed, 27 Oct 2010 18:53:25 +0000 (+0000)
Subject: nebmods: Protect against callbacks removing themselves
X-Git-Url: http://git.nagiosprojects.org/?p=nagios.git;a=commitdiff_plain;h=34596d7d75e2219c96865ec38bd70f2a6a0113a2;hp=98d91d403850f4600f2e61af3064584581171666
nebmods: Protect against callbacks removing themselves
Previously a callback deregistering itself from the chain of
callbacks to run at the event-type the callback registered
as (err...), Nagios would segfault since the pointer to the
next callback couldn't be looked up.
This patch takes care of it, making it possible for a module
to unload the callback it's currently running.
Signed-off-by: Andreas Ericsson
Author: Andreas Ericsson
---
diff --git a/base/nebmods.c b/base/nebmods.c
index 1cebdbc..b6bfb43 100644
--- a/base/nebmods.c
+++ b/base/nebmods.c
@@ -554,7 +554,7 @@ int neb_deregister_callback(int callback_type, int (*callback_func)(int,void *))
/* make callbacks to modules */
int neb_make_callbacks(int callback_type, void *data){
- nebcallback *temp_callback=NULL;
+ nebcallback *temp_callback, *next_callback;
int (*callbackfunc)(int,void *);
register int cbresult=0;
int total_callbacks=0;
@@ -570,9 +570,11 @@ int neb_make_callbacks(int callback_type, void *data){
log_debug_info(DEBUGL_EVENTBROKER,1,"Making callbacks (type %d)...\n",callback_type);
/* make the callbacks... */
- for(temp_callback=neb_callback_list[callback_type];temp_callback!=NULL;temp_callback=temp_callback->next){
+ for(temp_callback = neb_callback_list[callback_type];temp_callback;temp_callback=next_callback) {
+ next_callback = temp_callback->next;
callbackfunc=temp_callback->callback_func;
cbresult=callbackfunc(callback_type,data);
+ temp_callback = next_callback;
total_callbacks++;
log_debug_info(DEBUGL_EVENTBROKER,2,"Callback #%d (type %d) return code = %d\n",total_callbacks,callback_type,cbresult);
This issue has been migrated from Redmine: https://dev.icinga.com/issues/1021
Created by mfriedrich on 2010-11-24 12:05:45 +00:00
Assignee: mfriedrich
Status: Resolved (closed on 2010-11-24 12:53:40 +00:00)
Target Version: 1.3
Last Update: 2010-11-24 12:53:40 +00:00 (in Redmine)
Changesets
2010-11-24 12:06:03 +00:00 by mfriedrich 373cb33
The text was updated successfully, but these errors were encountered: