[exim-cvs] Module loading working on FreeBSD (and unbreak).

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Exim Git Commits Mailing List
Date:  
À: exim-cvs
Sujet: [exim-cvs] Module loading working on FreeBSD (and unbreak).
Gitweb: http://git.exim.org/exim.git/commitdiff/56e0c4ce946ae13628c4349f982c3407e1019dd0
Commit:     56e0c4ce946ae13628c4349f982c3407e1019dd0
Parent:     a01ba0815be7209559968f44f3498136a7924527
Author:     Phil Pennock <pdp@???>
AuthorDate: Mon Jan 17 08:43:35 2011 -0500
Committer:  Phil Pennock <pdp@???>
CommitDate: Mon Jan 17 08:43:35 2011 -0500


    Module loading working on FreeBSD (and unbreak).


    (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 |    1 +
 src/src/drtables.c           |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/src/scripts/lookups-Makefile b/src/scripts/lookups-Makefile
index 31820ea..7f2dd1b 100755
--- a/src/scripts/lookups-Makefile
+++ b/src/scripts/lookups-Makefile
@@ -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"
diff --git a/src/src/drtables.c b/src/src/drtables.c
index 276c0e6..e54202f 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -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);