From 81d2db6f50c34db9ab7d405362695c8a9f8a0ff2 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 6 May 2010 17:37:51 +0200 Subject: [PATCH] Fix problem when sending Cancel event to plugin --- bacula/src/filed/fd_plugins.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 0cbf8d8458..044901c748 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -122,22 +122,28 @@ struct bacula_ctx { findINCEXE *include; /* pointer to include/exclude files */ }; -static bool is_plugin_disabled(JCR *jcr) +static bool is_plugin_disabled(bpContext *plugin_ctx) { bacula_ctx *b_ctx; - if (!jcr->plugin_ctx) { + if (!plugin_ctx) { return true; } - b_ctx = (bacula_ctx *)jcr->plugin_ctx->bContext; + b_ctx = (bacula_ctx *)plugin_ctx->bContext; return b_ctx->disabled; } +static bool is_plugin_disabled(JCR *jcr) +{ + return is_plugin_disabled(jcr->plugin_ctx); +} /** * Create a plugin event + * When receiving bEventCancelCommand, this function is called by an other thread. */ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) { + bpContext *plugin_ctx; bEvent event; Plugin *plugin; int i = 0; @@ -172,19 +178,15 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) i++; continue; } - jcr->plugin_ctx = &plugin_ctx_list[i++]; - jcr->plugin = plugin; - if (is_plugin_disabled(jcr)) { + plugin_ctx = &plugin_ctx_list[i++]; + if (is_plugin_disabled(plugin_ctx)) { continue; } - rc = plug_func(plugin)->handlePluginEvent(jcr->plugin_ctx, &event, value); + rc = plug_func(plugin)->handlePluginEvent(plugin_ctx, &event, value); if (rc != bRC_OK) { break; } } - - jcr->plugin = NULL; - jcr->plugin_ctx = NULL; return; } -- 2.39.5