You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/03/11 17:32:29 UTC
svn commit: r1455219 - in /httpd/httpd/branches/2.4.x: ./ STATUS
modules/filters/mod_ratelimit.c
Author: jim
Date: Mon Mar 11 16:32:28 2013
New Revision: 1455219
URL: http://svn.apache.org/r1455219
Log:
Merge r1439623 from trunk:
Fix error because of negative rate-limit
PR : 52964
Submitted by: Tianyin Xu <tixu cs ucsd edu>
Submitted by: jailletc36
Reviewed/backported by: jim
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/STATUS
httpd/httpd/branches/2.4.x/modules/filters/mod_ratelimit.c
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1439623
Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1455219&r1=1455218&r2=1455219&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Mar 11 16:32:28 2013
@@ -91,12 +91,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_rate_limit: Fix error because of negative rate-limit
- PR 52964 [ianyin Xu <tixu cs ucsd edu>]
- trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1439623
- 2.4.x patch: trunk patch applies.
- +1: jailletc36, fuankg, jim
-
* Set of easy patches to keep 2.4.x in line with trunk
1442865: Change bzero/bcopy into memset/memcpy (PR 54346)
1442759: Can't figure out why we allocate len+2 bytes here. Len+1 should be enough.
Modified: httpd/httpd/branches/2.4.x/modules/filters/mod_ratelimit.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/filters/mod_ratelimit.c?rev=1455219&r1=1455218&r2=1455219&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/filters/mod_ratelimit.c (original)
+++ httpd/httpd/branches/2.4.x/modules/filters/mod_ratelimit.c Mon Mar 11 16:32:28 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));