Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

[dev.icinga.com #1021] protect against callbacks removing themsevles in nebmods #459

Closed
icinga-migration opened this issue Nov 24, 2010 · 1 comment
Labels
Milestone

Comments

@icinga-migration
Copy link

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)


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);

Changesets

2010-11-24 12:06:03 +00:00 by mfriedrich 373cb33

core: protect against callbacks removing themsevles in nebmods (Andreas Ericsson) #1021

fixes #1021
@icinga-migration
Copy link
Author

Updated by mfriedrich on 2010-11-24 12:53:40 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset commit:"373cb3384c8dd1704357d27b366ba83360e2ea97".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant