diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-08-18 15:41:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-08-18 15:41:28 +0200 |
commit | ead0a3eec4d60193b1c157e74452ae888fddf2fb (patch) | |
tree | bf416bd29513f8ddbb51d6b16f3c68e3358d4bd1 /src/util/plugin.c | |
parent | 69844eacf3e43ad882c38f4d954fb5f5dd5a848b (diff) | |
download | gnunet-ead0a3eec4d60193b1c157e74452ae888fddf2fb.tar.gz gnunet-ead0a3eec4d60193b1c157e74452ae888fddf2fb.zip |
-misc cleanups
Diffstat (limited to 'src/util/plugin.c')
-rw-r--r-- | src/util/plugin.c | 68 |
1 files changed, 5 insertions, 63 deletions
diff --git a/src/util/plugin.c b/src/util/plugin.c index 6ee41eec9..ffbae06ff 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -124,7 +124,8 @@ plugin_fini (void) | |||
124 | GNUNET_free (old_dlsearchpath); | 124 | GNUNET_free (old_dlsearchpath); |
125 | old_dlsearchpath = NULL; | 125 | old_dlsearchpath = NULL; |
126 | } | 126 | } |
127 | lt_dlexit (); | 127 | if (NULL == getenv ("VALGRINDING_PLUGINS")) |
128 | lt_dlexit (); | ||
128 | } | 129 | } |
129 | 130 | ||
130 | 131 | ||
@@ -162,16 +163,7 @@ resolve_function (struct PluginList *plug, | |||
162 | } | 163 | } |
163 | 164 | ||
164 | 165 | ||
165 | /** | 166 | enum GNUNET_GenericReturnValue |
166 | * Test if a plugin exists. | ||
167 | * | ||
168 | * Note that the library must export a symbol called | ||
169 | * `library_name_init` for the test to succeed. | ||
170 | * | ||
171 | * @param library_name name of the plugin to test if it is installed | ||
172 | * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not | ||
173 | */ | ||
174 | int | ||
175 | GNUNET_PLUGIN_test (const char *library_name) | 167 | GNUNET_PLUGIN_test (const char *library_name) |
176 | { | 168 | { |
177 | void *libhandle; | 169 | void *libhandle; |
@@ -201,18 +193,6 @@ GNUNET_PLUGIN_test (const char *library_name) | |||
201 | } | 193 | } |
202 | 194 | ||
203 | 195 | ||
204 | /** | ||
205 | * Setup plugin (runs the `init` callback and returns whatever `init` | ||
206 | * returned). If `init` returns NULL, the plugin is unloaded. | ||
207 | * | ||
208 | * Note that the library must export symbols called | ||
209 | * `library_name_init` and `library_name_done`. These will be called | ||
210 | * when the library is loaded and unloaded respectively. | ||
211 | * | ||
212 | * @param library_name name of the plugin to load | ||
213 | * @param arg argument to the plugin initialization function | ||
214 | * @return whatever the initialization function returned | ||
215 | */ | ||
216 | void * | 196 | void * |
217 | GNUNET_PLUGIN_load (const char *library_name, | 197 | GNUNET_PLUGIN_load (const char *library_name, |
218 | void *arg) | 198 | void *arg) |
@@ -257,14 +237,6 @@ GNUNET_PLUGIN_load (const char *library_name, | |||
257 | } | 237 | } |
258 | 238 | ||
259 | 239 | ||
260 | /** | ||
261 | * Unload plugin (runs the `done` callback and returns whatever `done` | ||
262 | * returned). The plugin is then unloaded. | ||
263 | * | ||
264 | * @param library_name name of the plugin to unload | ||
265 | * @param arg argument to the plugin shutdown function | ||
266 | * @return whatever the shutdown function returned | ||
267 | */ | ||
268 | void * | 240 | void * |
269 | GNUNET_PLUGIN_unload (const char *library_name, | 241 | GNUNET_PLUGIN_unload (const char *library_name, |
270 | void *arg) | 242 | void *arg) |
@@ -295,7 +267,8 @@ GNUNET_PLUGIN_unload (const char *library_name, | |||
295 | prev->next = pos->next; | 267 | prev->next = pos->next; |
296 | if (NULL != done) | 268 | if (NULL != done) |
297 | ret = done (arg); | 269 | ret = done (arg); |
298 | lt_dlclose (pos->handle); | 270 | if (NULL == getenv ("VALGRINDING_PLUGINS")) |
271 | lt_dlclose (pos->handle); | ||
299 | GNUNET_free (pos->name); | 272 | GNUNET_free (pos->name); |
300 | GNUNET_free (pos); | 273 | GNUNET_free (pos); |
301 | if (NULL == plugins) | 274 | if (NULL == plugins) |
@@ -381,23 +354,6 @@ find_libraries (void *cls, | |||
381 | } | 354 | } |
382 | 355 | ||
383 | 356 | ||
384 | /** | ||
385 | * Load all compatible plugins with the given base name. | ||
386 | * | ||
387 | * Note that the library must export symbols called | ||
388 | * `basename_ANYTHING_init` and `basename_ANYTHING__done`. These will | ||
389 | * be called when the library is loaded and unloaded respectively. | ||
390 | * | ||
391 | * If you are writing a service to which third-party applications can connect, | ||
392 | * like GNUnet's own GNS service for example, you should use | ||
393 | * #GNUNET_PLUGIN_load_all_in_context instead of this function, passing your | ||
394 | * service's project data as context. | ||
395 | * | ||
396 | * @param basename basename of the plugins to load | ||
397 | * @param arg argument to the plugin initialization function | ||
398 | * @param cb function to call for each plugin found | ||
399 | * @param cb_cls closure for @a cb | ||
400 | */ | ||
401 | void | 357 | void |
402 | GNUNET_PLUGIN_load_all (const char *basename, | 358 | GNUNET_PLUGIN_load_all (const char *basename, |
403 | void *arg, | 359 | void *arg, |
@@ -425,20 +381,6 @@ GNUNET_PLUGIN_load_all (const char *basename, | |||
425 | } | 381 | } |
426 | 382 | ||
427 | 383 | ||
428 | /** | ||
429 | * Load all compatible plugins with the given base name while inside the given | ||
430 | * context (i.e. a specific project data structure.) | ||
431 | * | ||
432 | * Note that the library must export symbols called `basename_ANYTHING_init` | ||
433 | * and `basename_ANYTHING__done`. These will be called when the library is | ||
434 | * loaded and unloaded respectively. | ||
435 | * | ||
436 | * @param ctx the context used to find the plugins | ||
437 | * @param basename basename of the plugins to load | ||
438 | * @param arg argument to the plugin initialization function | ||
439 | * @param cb function to call for each plugin found | ||
440 | * @param cb_cls closure for @a cb | ||
441 | */ | ||
442 | void | 384 | void |
443 | GNUNET_PLUGIN_load_all_in_context (const struct GNUNET_OS_ProjectData *ctx, | 385 | GNUNET_PLUGIN_load_all_in_context (const struct GNUNET_OS_ProjectData *ctx, |
444 | const char *basename, | 386 | const char *basename, |