X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fplugin.c;h=b3d5973178dffed19411af5d5acea45a99b718e3;hb=703c09231bca96e2e5d680ead4b471ec9e276ef5;hp=dc3717b3dcdf468a290b2b4d2e7214397fb017b2;hpb=923589c5a145693bfd172fd9b211a50c3ab8f1b1;p=sysdb.git diff --git a/src/core/plugin.c b/src/core/plugin.c index dc3717b..b3d5973 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -442,7 +442,8 @@ module_init(const char *name, lt_dlhandle lh, sdb_plugin_info_t *info) } /* module_init */ static int -module_load(const char *name, const sdb_plugin_ctx_t *plugin_ctx) +module_load(const char *basedir, const char *name, + const sdb_plugin_ctx_t *plugin_ctx) { char base_name[name ? strlen(name) + 1 : 1]; const char *name_ptr; @@ -467,8 +468,10 @@ module_load(const char *name, const sdb_plugin_ctx_t *plugin_ctx) } strcat(base_name, name_ptr); - snprintf(filename, sizeof(filename), "%s/%s.so", - PKGLIBDIR, base_name); + if (! basedir) + basedir = PKGLIBDIR; + + snprintf(filename, sizeof(filename), "%s/%s.so", basedir, base_name); filename[sizeof(filename) - 1] = '\0'; if (access(filename, R_OK)) { @@ -575,7 +578,8 @@ plugin_add_callback(sdb_llist_t **list, const char *type, */ int -sdb_plugin_load(const char *name, const sdb_plugin_ctx_t *plugin_ctx) +sdb_plugin_load(const char *basedir, const char *name, + const sdb_plugin_ctx_t *plugin_ctx) { ctx_t *ctx; @@ -612,7 +616,7 @@ sdb_plugin_load(const char *name, const sdb_plugin_ctx_t *plugin_ctx) return 0; } - return module_load(name, plugin_ctx); + return module_load(basedir, name, plugin_ctx); } /* sdb_plugin_load */ int @@ -1005,6 +1009,9 @@ sdb_plugin_collector_loop(sdb_plugin_loop_t *loop) sdb_log(SDB_LOG_ERR, "core: Failed to sleep " "in collector main loop: %s", sdb_strerror(errno, errbuf, sizeof(errbuf))); + sdb_llist_insert_sorted(collector_list, obj, + plugin_cmp_next_update); + sdb_object_deref(obj); return -1; } errno = 0; @@ -1106,12 +1113,11 @@ sdb_plugin_log(int prio, const char *msg) sdb_llist_iter_t *iter; int ret = -1; + _Bool logged = 0; + if (! msg) return 0; - if (! sdb_llist_len(log_list)) - return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg); - iter = sdb_llist_get_iter(log_list); while (sdb_llist_iter_has_next(iter)) { sdb_plugin_log_cb callback; @@ -1124,8 +1130,15 @@ sdb_plugin_log(int prio, const char *msg) tmp = callback(prio, msg, SDB_PLUGIN_CB(obj)->cb_user_data); if (tmp > ret) ret = tmp; + + if (SDB_PLUGIN_CB(obj)->cb_ctx) + logged = 1; + /* else: this is an internally registered callback */ } sdb_llist_iter_destroy(iter); + + if (! logged) + return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg); return ret; } /* sdb_plugin_log */