From: Marco van Wieringen Date: Fri, 23 Sep 2011 10:51:59 +0000 (+0200) Subject: Fix bug #1764 plugin_list shadows global variable of mysql 5.5 X-Git-Tag: Release-7.0.0~558 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a06f0589c1ac64c8b30c3286e76859f68a42c301;p=bacula%2Fbacula Fix bug #1764 plugin_list shadows global variable of mysql 5.5 --- diff --git a/bacula/src/dird/dir_plugins.c b/bacula/src/dird/dir_plugins.c index 1b579ac0b6..3c6761cfc4 100644 --- a/bacula/src/dird/dir_plugins.c +++ b/bacula/src/dird/dir_plugins.c @@ -74,7 +74,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) Plugin *plugin; int i = 0; - if (!plugin_list || !jcr || !jcr->plugin_ctx_list) { + if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) { return; } @@ -83,7 +83,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) Dmsg2(dbglvl, "plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { bRC rc; rc = plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event, value); if (rc != bRC_OK) { @@ -115,7 +115,7 @@ void load_dir_plugins(const char *plugin_dir) return; } - plugin_list = New(alist(10, not_owned_by_alist)); + bplugin_list = New(alist(10, not_owned_by_alist)); load_plugins((void *)&binfo, (void *)&bfuncs, plugin_dir, plugin_type, NULL); dbg_plugin_add_hook(dump_dir_plugin); } @@ -128,11 +128,11 @@ void new_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list) { + if (!bplugin_list) { return; } - int num = plugin_list->size(); + int num = bplugin_list->size(); if (num == 0) { return; @@ -142,7 +142,7 @@ void new_plugins(JCR *jcr) bpContext *plugin_ctx_list = jcr->plugin_ctx_list; Dmsg2(dbglvl, "Instantiate plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Start a new instance of each plugin */ plugin_ctx_list[i].bContext = (void *)jcr; plugin_ctx_list[i].pContext = NULL; @@ -158,13 +158,13 @@ void free_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list || !jcr->plugin_ctx_list) { + if (!bplugin_list || !jcr->plugin_ctx_list) { return; } bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Free instance plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Free the plugin instance */ plug_func(plugin)->freePlugin(&plugin_ctx_list[i]); plugin_ctx_list[i].bContext = NULL; diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 26f03e51aa..2af39ad5af 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -305,12 +305,12 @@ void list_dir_status_header(UAContext *ua) edit_uint64_with_commas(sm_max_buffers, b5)); /* TODO: use this function once for all daemons */ - if (debug_level > 0 && plugin_list->size() > 0) { + if (debug_level > 0 && bplugin_list->size() > 0) { int len; Plugin *plugin; POOL_MEM msg(PM_FNAME); pm_strcpy(msg, " Plugin: "); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { len = pm_strcat(msg, plugin->file); if (len > 80) { pm_strcat(msg, "\n "); diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index a4cd7c0e49..210f931827 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -160,7 +160,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) bool call_if_canceled = false; bRC rc; - if (!plugin_list || !jcr || !jcr->plugin_ctx_list) { + if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) { return; /* Return if no plugins loaded */ } @@ -210,7 +210,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) * Pass event to every plugin (except if name is set). If name * is set, we pass it only to the plugin with that name. */ - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { if (name && !for_this_plug(plugin, name, len)) { i++; continue; @@ -236,7 +236,7 @@ bool plugin_check_file(JCR *jcr, char *fname) int rc = bRC_OK; int i = 0; - if (!plugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) { + if (!bplugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) { return false; /* Return if no plugins loaded */ } @@ -245,7 +245,7 @@ bool plugin_check_file(JCR *jcr, char *fname) Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); /* Pass event to every plugin */ - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { jcr->plugin_ctx = &plugin_ctx_list[i++]; jcr->plugin = plugin; if (is_plugin_disabled(jcr)) { @@ -326,7 +326,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) POOL_MEM fname(PM_FNAME); POOL_MEM link(PM_FNAME); - if (!plugin_list || !jcr->plugin_ctx_list || jcr->is_job_canceled()) { + if (!bplugin_list || !jcr->plugin_ctx_list || jcr->is_job_canceled()) { Jmsg1(jcr, M_FATAL, 0, "Command plugin \"%s\" requested, but is not loaded.\n", cmd); return 1; /* Return if no plugins loaded */ } @@ -340,7 +340,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) } /* Note, we stop the loop on the first plugin that matches the name */ - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { Dmsg4(dbglvl, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->file_len, cmd, len); if (!for_this_plug(plugin, cmd, len)) { i++; @@ -557,7 +557,7 @@ bool plugin_name_stream(JCR *jcr, char *name) /* * Search for correct plugin as specified on the command */ - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { bEvent event; Dmsg3(dbglvl, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); if (!for_this_plug(plugin, cmd, len)) { @@ -724,13 +724,13 @@ void load_fd_plugins(const char *plugin_dir) return; } - plugin_list = New(alist(10, not_owned_by_alist)); + bplugin_list = New(alist(10, not_owned_by_alist)); if (!load_plugins((void *)&binfo, (void *)&bfuncs, plugin_dir, plugin_type, is_plugin_compatible)) { /* Either none found, or some error */ - if (plugin_list->size() == 0) { - delete plugin_list; - plugin_list = NULL; + if (bplugin_list->size() == 0) { + delete bplugin_list; + bplugin_list = NULL; Dmsg0(dbglvl, "No plugins loaded\n"); return; } @@ -747,7 +747,7 @@ void load_fd_plugins(const char *plugin_dir) * Verify that the plugin is acceptable, and print information * about it. */ - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { Jmsg(NULL, M_INFO, 0, _("Loaded plugin: %s\n"), plugin->file); Dmsg1(dbglvl, "Loaded plugin: %s\n", plugin->file); } @@ -799,7 +799,7 @@ static bool is_plugin_compatible(Plugin *plugin) /** * Create a new instance of each plugin for this Job - * Note, plugin_list can exist but jcr->plugin_ctx_list can + * Note, bplugin_list can exist but jcr->plugin_ctx_list can * be NULL if no plugins were loaded. */ void new_plugins(JCR *jcr) @@ -807,7 +807,7 @@ void new_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list) { + if (!bplugin_list) { Dmsg0(dbglvl, "plugin list is NULL\n"); return; } @@ -815,7 +815,7 @@ void new_plugins(JCR *jcr) return; } - int num = plugin_list->size(); + int num = bplugin_list->size(); if (num == 0) { Dmsg0(dbglvl, "No plugins loaded\n"); @@ -826,7 +826,7 @@ void new_plugins(JCR *jcr) bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Instantiate plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Start a new instance of each plugin */ bacula_ctx *b_ctx = (bacula_ctx *)malloc(sizeof(bacula_ctx)); memset(b_ctx, 0, sizeof(bacula_ctx)); @@ -847,13 +847,13 @@ void free_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list || !jcr->plugin_ctx_list) { + if (!bplugin_list || !jcr->plugin_ctx_list) { return; /* no plugins, nothing to do */ } bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Free instance plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Free the plugin instance */ plug_func(plugin)->freePlugin(&plugin_ctx_list[i]); free(plugin_ctx_list[i++].bContext); /* free Bacula private context */ diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 1a1a0130ea..1306a8bc64 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -149,11 +149,11 @@ static void list_status_header(STATUS_PKT *sp) len = Mmsg(msg, _(" Sizeof: boffset_t=%d size_t=%d debug=%d trace=%d\n"), sizeof(boffset_t), sizeof(size_t), debug_level, get_trace()); sendit(msg.c_str(), len, sp); - if (debug_level > 0 && plugin_list->size() > 0) { + if (debug_level > 0 && bplugin_list->size() > 0) { Plugin *plugin; int len; pm_strcpy(msg, "Plugin: "); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { len = pm_strcat(msg, plugin->file); if (len > 80) { pm_strcat(msg, "\n "); diff --git a/bacula/src/lib/plugins.c b/bacula/src/lib/plugins.c index 0399c48736..7b2fce7831 100644 --- a/bacula/src/lib/plugins.c +++ b/bacula/src/lib/plugins.c @@ -50,7 +50,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); static const int dbglvl = 50; /* All loaded plugins */ -alist *plugin_list = NULL; +alist *bplugin_list = NULL; /* * Create a new plugin "class" entry and enter it in the @@ -199,7 +199,7 @@ bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, } found = true; /* found a plugin */ - plugin_list->append(plugin); + bplugin_list->append(plugin); } get_out: @@ -222,10 +222,10 @@ void unload_plugins() { Plugin *plugin; - if (!plugin_list) { + if (!bplugin_list) { return; } - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Shut it down and unload it */ plugin->unloadPlugin(); dlclose(plugin->pHandle); @@ -234,8 +234,8 @@ void unload_plugins() } free(plugin); } - delete plugin_list; - plugin_list = NULL; + delete bplugin_list; + bplugin_list = NULL; } /* @@ -258,10 +258,10 @@ void dbg_print_plugin(FILE *fp) Plugin *plugin; fprintf(fp, "Attempt to dump plugins. Hook count=%d\n", dbg_plugin_hook_count); - if (!plugin_list) { + if (!bplugin_list) { return; } - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { for(int i=0; i < dbg_plugin_hook_count; i++) { // dbg_plugin_hook_t *fct = dbg_plugin_hooks[i]; fprintf(fp, "Plugin %p name=\"%s\" disabled=%d\n", diff --git a/bacula/src/lib/plugins.h b/bacula/src/lib/plugins.h index 2d45f916bf..fc2a6d0c93 100644 --- a/bacula/src/lib/plugins.h +++ b/bacula/src/lib/plugins.h @@ -40,7 +40,7 @@ ****************************************************************************/ #ifndef BUILD_PLUGIN -extern DLL_IMP_EXP alist *plugin_list; +extern DLL_IMP_EXP alist *bplugin_list; #endif /* Universal return codes from all plugin functions */ diff --git a/bacula/src/plugins/sd/main.c b/bacula/src/plugins/sd/main.c index fd8460f1fa..ffdd53d2ec 100644 --- a/bacula/src/plugins/sd/main.c +++ b/bacula/src/plugins/sd/main.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) bEvent event; Plugin *plugin; - plugin_list = New(alist(10, not_owned_by_alist)); + bplugin_list = New(alist(10, not_owned_by_alist)); ctx.bContext = NULL; ctx.pContext = NULL; @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) load_plugins((void *)&bfuncs, plugin_dir, plugin_type); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { printf("bacula: plugin_size=%d plugin_version=%d\n", pref(plugin)->size, pref(plugin)->interface); printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n", diff --git a/bacula/src/stored/sd_plugins.c b/bacula/src/stored/sd_plugins.c index 7bbc7f549a..e77c300f85 100644 --- a/bacula/src/stored/sd_plugins.c +++ b/bacula/src/stored/sd_plugins.c @@ -75,7 +75,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) Plugin *plugin; int i = 0; - if (!plugin_list) { + if (!bplugin_list) { return; } @@ -84,7 +84,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) Dmsg2(dbglvl, "plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { bRC rc; rc = plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event, value); if (rc != bRC_OK) { @@ -116,7 +116,7 @@ void load_sd_plugins(const char *plugin_dir) return; } - plugin_list = New(alist(10, not_owned_by_alist)); + bplugin_list = New(alist(10, not_owned_by_alist)); load_plugins((void *)&binfo, (void *)&bfuncs, plugin_dir, plugin_type, NULL); dbg_plugin_add_hook(dump_sd_plugin); } @@ -129,11 +129,11 @@ void new_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list) { + if (!bplugin_list) { return; } - int num = plugin_list->size(); + int num = bplugin_list->size(); if (num == 0) { return; @@ -143,7 +143,7 @@ void new_plugins(JCR *jcr) bpContext *plugin_ctx_list = jcr->plugin_ctx_list; Dmsg2(dbglvl, "Instantiate plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Start a new instance of each plugin */ plugin_ctx_list[i].bContext = (void *)jcr; plugin_ctx_list[i].pContext = NULL; @@ -159,13 +159,13 @@ void free_plugins(JCR *jcr) Plugin *plugin; int i = 0; - if (!plugin_list) { + if (!bplugin_list) { return; } bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; Dmsg2(dbglvl, "Free instance plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); - foreach_alist(plugin, plugin_list) { + foreach_alist(plugin, bplugin_list) { /* Free the plugin instance */ plug_func(plugin)->freePlugin(&plugin_ctx_list[i++]); }