Module loading working on FreeBSD (and unbreak).
authorPhil Pennock <pdp@exim.org>
Mon, 17 Jan 2011 13:43:35 +0000 (08:43 -0500)
committerPhil Pennock <pdp@exim.org>
Mon, 17 Jan 2011 13:43:35 +0000 (08:43 -0500)
(1) Commit eec525c43adade97ff94d839810faf7cb35bd87f broke module
    support, because we *do* still need some exported variable
    definitions, as for a module to actually work, we need the
    per-module _INCLUDE/_LIBS settings.

(2) FreeBSD's nsdispatch() will leave dlerror() returning a complaint
    about "_nss_cache_cycle_prevention_function"; we need to clear the
    error state before the dlsym() call, so that any error found
    afterwards must have come from that dlsym() call.  Fix is just an
    extra call to dlerror(), which should be portable.

I can now use sqlite3 from a module, in FreeBSD.

src/scripts/lookups-Makefile
src/src/drtables.c

index 31820ea2fae7fcb2173580bb6128da196d1b4a54..7f2dd1b9e60b2b93bb55c76c5654f49f9532d891 100755 (executable)
@@ -47,6 +47,7 @@ emit_module_rule() {
   if want_dynamic "$lookup_name"
   then
     echo "MODS += ${mod_name}.so"
+    grep "^LOOKUP_${lookup_name}_" "$defs_source"
     echo "LOOKUP_${mod_name}_INCLUDE = \$(LOOKUP_${lookup_name}_INCLUDE)"
     echo "LOOKUP_${mod_name}_LIBS = \$(LOOKUP_${lookup_name}_LIBS)"
   elif want_at_all "$lookup_name"
index 276c0e67b87943424816ddd6d3db2e81d22a4d54..e54202f430cf3a2cf1ac420cac78c329271ad15b 100644 (file)
@@ -518,6 +518,13 @@ extern lookup_module_info whoson_lookup_module_info;
           continue;
         }
 
+        /* FreeBSD nsdispatch() can trigger dlerror() errors about
+         * _nss_cache_cycle_prevention_function; we need to clear the dlerror()
+         * state before calling dlsym(), so that any error afterwards only
+         * comes from dlsym().
+         */
+        errormsg = dlerror();
+
         info = (struct lookup_module_info*) dlsym(dl, "_lookup_module_info");
         if ((errormsg = dlerror()) != NULL) {
           fprintf(stderr, "%s does not appear to be a lookup module (%s)\n", name, errormsg);