[mirrorbrain-commits] [mod_asn] r86 - /trunk/mod_asn.c

From: <poeml_at_mirrorbrain.org>
Date: Sun, 05 Sep 2010 18:58:51 -0000
Author: poeml
Date: Sun Sep  5 20:58:50 2010
New Revision: 86

URL: http://svn.mirrorbrain.org/viewvc/mod_asn?rev=86&view=rev
Log:
- remove the compile time check for the APR/APR-Util version and make it a
  runtime check. This means that the correct database access semantics are used
  even when mod_asn is used with a different library than it was compiled with.
  Improving the fix for issue #7.

Modified:
    trunk/mod_asn.c

Modified: trunk/mod_asn.c
URL: http://svn.mirrorbrain.org/viewvc/mod_asn/trunk/mod_asn.c?rev=86&r1=85&r2=86&view=diff
==============================================================================
--- trunk/mod_asn.c (original)
+++ trunk/mod_asn.c Sun Sep  5 20:58:50 2010
_at_@ -36,6 +36,7 @@
 #include "http_protocol.h"
 
 #include "apr_version.h"
+#include "apu_version.h"
 #include "apr_strings.h"
 #include "apr_lib.h"
 #include "apr_dbd.h"
_at_@ -84,6 +85,9 @@
 static ap_dbd_t *(*asn_dbd_open_fn)(apr_pool_t*, server_rec*) = NULL;
 static void (*asn_dbd_close_fn)(server_rec*, ap_dbd_t*) = NULL;
 static void (*asn_dbd_prepare_fn)(server_rec*, const char*, const char*) = NULL;
+
+static apr_version_t vsn;
+static int dbd_first_row;
 
 
 static void debugLog(const request_rec *r, const asn_dir_conf *cfg,
_at_@ -108,6 +112,17 @@
 static int asn_post_config(apr_pool_t *pconf, apr_pool_t *plog, 
                                apr_pool_t *ptemp, server_rec *s)
 {
+    apr_version(&vsn);
+    ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
+                 "[mod_asn] compiled with APR/APR-Util %s/%s",
+                 APR_VERSION_STRING, APU_VERSION_STRING);
+
+    if ((vsn.major == 1) && (vsn.minor == 2)) {
+        dbd_first_row = 0;
+    } else {
+        dbd_first_row = 1;
+    }
+
     ap_add_version_component(pconf, VERSION_COMPONENT);
 
     /* make sure that mod_dbd is loaded */
_at_@ -318,14 +333,8 @@
         return DECLINED;
     }
 
-#if (APR_MAJOR_VERSION == 1 && APR_MINOR_VERSION == 2)
-#define DBD_FIRST_ROW 0
-#else
-#define DBD_FIRST_ROW 1
-#endif
-
     /* we care only about the 1st row, because our query uses 'limit 1' */
-    rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, DBD_FIRST_ROW);
+    rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, dbd_first_row);
     if (rv != APR_SUCCESS) {
         if (rv == -1) {
             /* not an error - might be a private IP, for instance */
_at_@ -351,7 +360,7 @@
     }
 
     /* clear the cursor by accessing invalid row */
-    rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, DBD_FIRST_ROW + 1);
+    rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, dbd_first_row + 1);
     if (rv != -1) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "[mod_asn] found one row too much looking up %s", 




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Sun Sep 05 2010 - 18:58:53 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT