[mirrorbrain-commits] r8238 - /trunk/mod_mirrorbrain/mod_mirrorbrain.c

From: <poeml_at_mirrorbrain.org>
Date: Wed, 23 Feb 2011 21:27:06 -0000
Author: poeml
Date: Wed Feb 23 22:27:03 2011
New Revision: 8238

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8238&view=rev
Log:
mod_mirrorbrain:
- untested fix for issue #84: handle a failed database connection acquisition
  correctly also when fallback mirrors are configured

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=8238&r1=8237&r2=8238&view=diff
==============================================================================
--- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original)
+++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Wed Feb 23 22:27:03 2011
_at_@ -1356,7 +1356,7 @@
     const char *as;                             /* autonomous system */
     const char *prefix;                         /* network prefix */
     int i;
-    int mirror_cnt;
+    int mirror_cnt = 0;
     apr_size_t len, nr;
     mirror_entry_t *new;
     mirror_entry_t *mirror;
_at_@ -1940,9 +1940,11 @@
     }
 
 
-    statement = apr_hash_get(dbd->prepared, scfg->query_label, APR_HASH_KEY_STRING);
-
-    if (statement == NULL) {
+    if (dbd) {
+        statement = apr_hash_get(dbd->prepared, scfg->query_label, APR_HASH_KEY_STRING);
+    }
+
+    if (!dbd || !statement) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, 
                       "[mod_mirrorbrain] Could not get prepared statement labelled '%s'",
                       scfg->query_label);
_at_@ -1966,13 +1968,15 @@
                       "DBDParams must be unique. The same string cannot be used "
                       "in two vhosts.");
 
-        return DECLINED;
+        if (apr_is_empty_array(cfg->fallbacks)) {
+            return DECLINED;
+        }
     }
 
 
     /* no need to escape for the SQL query because we use a prepared 
      * statement with bound parameters */
-    if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement, 
+    if (dbd && apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement, 
                 1, /* we don't need random access actually, but 
                       without it the mysql driver doesn't return results
                       once apr_dbd_num_tuples() has been called; 
_at_@ -1985,7 +1989,9 @@
         }
     }
 
-    mirror_cnt = apr_dbd_num_tuples(dbd->driver, res);
+    if (dbd) {
+        mirror_cnt = apr_dbd_num_tuples(dbd->driver, res);
+    }
 
     if (mirror_cnt > 0) {
         debugLog(r, cfg, "Found %d mirror%s", mirror_cnt,




_______________________________________________
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 Wed Feb 23 2011 - 21:27:13 GMT

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