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

From: <poeml_at_mirrorbrain.org>
Date: Wed, 01 Sep 2010 12:42:50 -0000
Author: poeml
Date: Wed Sep  1 14:42:50 2010
New Revision: 8089

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8089&view=rev
Log:
mod_mirrorbrain:
- fix some variable types from int to apr_off_t, using apr_atoi64() instead of
  atoi(). This applies to: min_size, file_maxsize, and the database identifier
  of a hash row. This at least fixes the info message given when a file is
  excluded from redirection due to its size. The checks seemed to work
  nevertheless, because the min_size numbers were small and file_maxsize
  numbers large, which helped to get the correct result when comparing.

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=8089&r1=8088&r2=8089&view=diff
==============================================================================
--- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original)
+++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Wed Sep  1 14:42:50 2010
_at_@ -195,7 +195,7 @@
     unsigned char prefix_only;
     int score;
     const char *baseurl;
-    int file_maxsize;
+    apr_off_t file_maxsize;
     char *other_countries;    /* comma-separated 2-letter strings */
     int rank;
 };
_at_@ -203,7 +203,7 @@
 /* verification hashes of a file */
 typedef struct hashbag hashbag_t;
 struct hashbag {
-    int id;
+    apr_off_t id;
     const char *md5hex;
     const char *sha1hex;
     const char *sha256hex;
_at_@ -221,7 +221,7 @@
 {
     int engine_on;
     int debug;
-    int min_size;
+    apr_off_t min_size;
     int handle_headrequest_locally;
     const char *mirror_base;
     apr_array_header_t *fallbacks;
_at_@ -470,7 +470,7 @@
                                   const char *arg1)
 {
     mb_dir_conf *cfg = (mb_dir_conf *) config;
-    cfg->min_size = atoi(arg1);
+    cfg->min_size = apr_atoi64(arg1);
     if (cfg->min_size < 0)
         return "MirrorBrainMinSize requires a non-negative integer.";
     return NULL;
_at_@ -943,7 +943,7 @@
     if ((val = apr_dbd_get_entry(dbd->driver, row, col++)) == NULL) 
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] dbd: got NULL for file_id");
     else
-        h->id = atoi(val);
+        h->id = apr_atoi64(val);
 
     if ((val = apr_dbd_get_entry(dbd->driver, row, col++)) == NULL) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] dbd: got NULL for md5");
_at_@ -1296,8 +1296,9 @@
 
         /* is the requested file too small to be worth a redirect? */
         if (!fakefile && (r->finfo.size < cfg->min_size)) {
-            debugLog(r, cfg, "File '%s' too small (%lld bytes, less than %lld)", 
-                    r->filename, r->finfo.size, cfg->min_size);
+            debugLog(r, cfg, "File '%s' too small (%s bytes, less than %s)", 
+                    r->filename, apr_off_t_toa(r->pool, r->finfo.size), 
+                    apr_off_t_toa(r->pool, cfg->min_size));
             return DECLINED;
         }
 
_at_@ -1743,7 +1744,7 @@
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] apr_dbd_get_entry found NULL for file_maxsize");
             unusable = 1;
         } else
-            new->file_maxsize = atoi(val);
+            new->file_maxsize = apr_atoi64(val);
 
 
 
_at_@ -1760,7 +1761,6 @@
         /* not using thread-safe rand_r() here, because it shouldn't make 
          * a real difference here */
         new->rank = (rand()>>16) * ((RAND_MAX>>16) / new->score);
-        /* debugLog(r, cfg, "Found mirror #%d '%s'", new->id, new->identifier); */
         
 
 #ifdef WITH_MEMCACHE
_at_@ -2177,7 +2177,8 @@
 
         if (hashbag != NULL) {
             if (hashbag->id) {
-                ap_rprintf(r, "    <!-- internal id: %d -->\n", hashbag->id);
+                ap_rprintf(r, "    <!-- internal id: %s -->\n", 
+                           apr_off_t_toa(r->pool, hashbag->id));
             }
 
             switch (rep) {
_at_@ -2695,7 +2696,7 @@
                                       "i%de"
                                   "6:pieces"
                                       "%d:", apr_off_t_toa(r->pool, r->finfo.size),
-                                                           strlen(basename), 
+                                             strlen(basename), 
                                              basename,
                                              hashbag->sha1piecesize,
                                              (hashbag->sha1pieceshex->nelts * SHA1_DIGESTSIZE));




_______________________________________________
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 Sep 01 2010 - 12:42:55 GMT

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