httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaillet...@apache.org
Subject svn commit: r1439623 - /httpd/httpd/trunk/modules/filters/mod_ratelimit.c
Date Mon, 28 Jan 2013 20:57:11 GMT
Author: jailletc36
Date: Mon Jan 28 20:57:10 2013
New Revision: 1439623

URL: http://svn.apache.org/viewvc?rev=1439623&view=rev
Log:
Fix error because of negative rate-limit
PR : 52964
Submitted by: Tianyin Xu <tixu cs ucsd edu>

Modified:
    httpd/httpd/trunk/modules/filters/mod_ratelimit.c

Modified: httpd/httpd/trunk/modules/filters/mod_ratelimit.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_ratelimit.c?rev=1439623&r1=1439622&r2=1439623&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_ratelimit.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_ratelimit.c Mon Jan 28 20:57:10 2013
@@ -74,6 +74,7 @@ rate_limit_filter(ap_filter_t *f, apr_bu
     if (ctx == NULL) {
 
         const char *rl = NULL;
+        int ratelimit;
 
         /* no subrequests. */
         if (f->r->main != NULL) {
@@ -87,22 +88,21 @@ rate_limit_filter(ap_filter_t *f, apr_bu
             ap_remove_output_filter(f);
             return ap_pass_brigade(f->next, bb);
         }
-
-        /* first run, init stuff */
-        ctx = apr_palloc(f->r->pool, sizeof(rl_ctx_t));
-        f->ctx = ctx;
-        ctx->speed = 0;
-        ctx->state = RATE_LIMIT;
-
+        
         /* rl is in kilo bytes / second  */
-        ctx->speed = atoi(rl) * 1024;
-
-        if (ctx->speed == 0) {
+        ratelimit = atoi(rl) * 1024;
+        if (ratelimit <= 0) {
             /* remove ourselves */
             ap_remove_output_filter(f);
             return ap_pass_brigade(f->next, bb);
         }
 
+        /* first run, init stuff */
+        ctx = apr_palloc(f->r->pool, sizeof(rl_ctx_t));
+        f->ctx = ctx;
+        ctx->state = RATE_LIMIT;
+        ctx->speed = ratelimit;
+
         /* calculate how many bytes / interval we want to send */
         /* speed is bytes / second, so, how many  (speed / 1000 % interval) */
         ctx->chunk_size = (ctx->speed / (1000 / RATE_INTERVAL_MS));



Mime
View raw message