Author: poeml Date: Sun Sep 5 22:08:40 2010 New Revision: 8107 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8107&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_mirrorbrain is used with a different library version than it was compiled with. Improving the fix for issue #7. N.B. A similar compile time check to pick an appropriate format string in the SQL query is still there. Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=8107&r1=8106&r2=8107&view=diff ============================================================================== --- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original) +++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Sun Sep 5 22:08:40 2010 _at_@ -71,6 +71,7 @@ #include "util_md5.h" #include "apr_version.h" +#include "apu_version.h" #include "apr_strings.h" #include "apr_lib.h" #include "apr_fnmatch.h" _at_@ -125,10 +126,8 @@ #define DEFAULT_MIN_MIRROR_SIZE 4096 #if (APR_MAJOR_VERSION == 1 && APR_MINOR_VERSION == 2) -#define DBD_FIRST_ROW 0 #define DBD_LLD_FMT "d" #else -#define DBD_FIRST_ROW 1 #define DBD_LLD_FMT "lld" #endif _at_@ -266,6 +265,9 @@ static ap_dbd_t *(*mb_dbd_acquire_fn)(request_rec*) = NULL; static void (*mb_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 mb_dir_conf *cfg, const char *fmt, ...) { _at_@ -299,6 +301,18 @@ static int mb_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_INFO, 0, s, + "[mod_mirrorbrain] compiled with APR/APR-Util %s/%s", + APR_VERSION_STRING, APU_VERSION_STRING); + if ((vsn.major == 1) && (vsn.minor == 2)) { + /* database access semantics were changed between 1.2 and 1.3 (strictly + * speaking, breaking the binary compatibility */ + dbd_first_row = 0; + } else { + dbd_first_row = 1; + } /* be visible in the server signature */ ap_add_version_component(pconf, VERSION_COMPONENT); _at_@ -936,7 +950,7 @@ } /* 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) { const char *errmsg = apr_dbd_error(dbd->driver, dbd->handle, rv); ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, _at_@ -1043,7 +1057,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_mirrorbrain] found too many rows when looking up hashes for %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.orgReceived on Sun Sep 05 2010 - 20:08:45 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT