]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix problem when sending Cancel event to plugin
authorEric Bollengier <eric@eb.homelinux.org>
Thu, 6 May 2010 15:37:51 +0000 (17:37 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:53:48 +0000 (16:53 +0200)
bacula/src/filed/fd_plugins.c

index 0cbf8d8458cc7da4e2822744d9db477e9410b130..044901c748d67c4e8e5cf86a7b35b763ce2a00e3 100644 (file)
@@ -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;
 }