dlerror not resetted on the *BSD: use the return of dlsym instead

Initial
Stephane Bortzmeyer 20 years ago
parent f4c3ceba52
commit b9c3f84c92

@ -431,13 +431,12 @@ 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);
/* RTLD_NOW makes dlopen fail silently on NetBSD */ plugin = dlopen (plugin_name, RTLD_NOW);
plugin = dlopen (plugin_name, RTLD_LAZY);
if (!plugin) if (!plugin)
{ /* retries with the absolute name */ { /* 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_LAZY); plugin = dlopen (complete_plugin_name, RTLD_NOW);
} }
if (!plugin) if (!plugin)
{ {
@ -446,10 +445,9 @@ main (argc, argv)
plugin_name, PLUGINS_DIR, dlerror ()); plugin_name, PLUGINS_DIR, dlerror ());
} }
plugin_init = dlsym (plugin, "init"); plugin_init = dlsym (plugin, "init");
dl_result = dlerror (); if (! plugin_init)
if (dl_result)
{ {
err_sys ("Cannot find init in %s: %s", plugin_name, dl_result); err_sys ("Cannot find init in %s: %s", plugin_name, dlerror());
} }
plugin_port_name = plugin_init (remaining, (const char **) leftover); plugin_port_name = plugin_init (remaining, (const char **) leftover);
if (plugin_port_name != NULL) if (plugin_port_name != NULL)
@ -457,22 +455,19 @@ main (argc, argv)
else else
port_name = 0; port_name = 0;
plugin_start = dlsym (plugin, "start"); plugin_start = dlsym (plugin, "start");
dl_result = dlerror (); if (! plugin_start)
if (dl_result)
{ {
err_sys ("Cannot find start in %s: %s", plugin_name, dl_result); err_sys ("Cannot find start in %s: %s", plugin_name, dlerror());
} }
plugin_execute = dlsym (plugin, "execute"); plugin_execute = dlsym (plugin, "execute");
dl_result = dlerror (); if (!plugin_execute)
if (dl_result)
{ {
err_sys ("Cannot find execute in %s: %s", plugin_name, dl_result); err_sys ("Cannot find execute in %s: %s", plugin_name, dlerror());
} }
plugin_terminate = dlsym (plugin, "terminate"); plugin_terminate = dlsym (plugin, "terminate");
dl_result = dlerror (); if (! plugin_terminate)
if (dl_result)
{ {
err_sys ("Cannot find terminate in %s: %s", plugin_name, dl_result); err_sys ("Cannot find terminate in %s: %s", plugin_name, dlerror());
} }
} }
if (!udp && !ttcp) if (!udp && !ttcp)

Loading…
Cancel
Save