* RTLD_LAZY and not RTLD_NOW (NetBSD problem)

* Indent of plugin code
This commit is contained in:
Stephane Bortzmeyer 2004-05-25 13:39:42 +00:00
parent 7671c535bc
commit 70c4dfb776

View File

@ -192,10 +192,7 @@ main (argc, argv)
} }
progname = (char *) argv[0]; progname = (char *) argv[0];
poptcon = poptGetContext (NULL, argc, poptcon = poptGetContext (NULL, argc, argv, options, 0);
argv,
options,
0);
while ((!module_find) && (result = poptGetNextOpt (poptcon)) != -1) while ((!module_find) && (result = poptGetNextOpt (poptcon)) != -1)
{ {
@ -434,15 +431,18 @@ main (argc, argv)
ext = strstr (plugin_name, ".so"); ext = strstr (plugin_name, ".so");
if ((ext == NULL) || (strcmp (ext, ".so") != 0)) if ((ext == NULL) || (strcmp (ext, ".so") != 0))
sprintf (plugin_name, "%s.so", plugin_name); sprintf (plugin_name, "%s.so", plugin_name);
plugin = dlopen (plugin_name, RTLD_NOW); /* RTLD_NOW makes dlopen fail silently on NetBSD */
if (!plugin) { /* retries with the absolute name */ plugin = dlopen (plugin_name, RTLD_LAZY);
if (!plugin)
{ /* retries with the absolute name */
complete_plugin_name = (char *) malloc (MAX_LINE); complete_plugin_name = (char *) malloc (MAX_LINE);
sprintf (complete_plugin_name, "%s/%s", PLUGINS_DIR, plugin_name); sprintf (complete_plugin_name, "%s/%s", PLUGINS_DIR, plugin_name);
plugin = dlopen (complete_plugin_name, RTLD_NOW); plugin = dlopen (complete_plugin_name, RTLD_LAZY);
} }
if (!plugin) if (!plugin)
{ {
err_sys ("Cannot load \"%s\" (I tried the short name, then the complete name in \"%s\"): %s", err_sys
("Cannot load \"%s\" (I tried the short name, then the complete name in \"%s\"): %s",
plugin_name, PLUGINS_DIR, dlerror ()); plugin_name, PLUGINS_DIR, dlerror ());
} }
plugin_init = dlsym (plugin, "init"); plugin_init = dlsym (plugin, "init");