/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "util_filter.h"
#include "mod_ratelimit.h"
typedef enum rl_state_e
{
} rl_state_e;
typedef struct rl_ctx_t
{
int speed;
int chunk_size;
} rl_ctx_t;
#if 0
{
apr_bucket *e;
int i = 0;
for (e = APR_BRIGADE_FIRST(bb);
}
}
#endif
static apr_status_t
{
int do_sleep = 0;
if (f->c->aborted) {
return APR_ECONNABORTED;
}
int ratelimit;
/* no subrequests. */
}
}
/* rl is in kilo bytes / second */
if (ratelimit <= 0) {
/* remove ourselves */
}
/* first run, init stuff */
/* calculate how many bytes / interval we want to send */
/* speed is bytes / second, so, how many (speed / 1000 % interval) */
}
apr_bucket *e;
}
/* Find where we 'stop' going full speed. */
for (e = APR_BRIGADE_FIRST(bb);
if (AP_RL_BUCKET_IS_END(e)) {
apr_bucket *f;
APR_RING_UNSPLICE(e, f, link);
apr_bucket, link);
break;
}
}
if (f->c->aborted) {
break;
}
if (rv != APR_SUCCESS) {
"rl: full speed brigade pass failed.");
}
}
for (e = APR_BRIGADE_FIRST(bb);
if (AP_RL_BUCKET_IS_START(e)) {
apr_bucket *f;
APR_RING_UNSPLICE(e, f, link);
apr_bucket, link);
break;
}
}
while (!APR_BRIGADE_EMPTY(bb)) {
if (f->c->aborted) {
break;
}
if (do_sleep) {
}
else {
do_sleep = 1;
}
"rl: partition failed.");
break;
}
apr_bucket *f;
APR_RING_UNSPLICE(f, e, link);
link);
}
else {
}
#if 0
brigade_dump(f->r, bb);
#endif
if (rv != APR_SUCCESS) {
"rl: brigade pass failed.");
break;
}
}
}
}
return rv;
}
static apr_status_t
{
*len = 0;
return APR_SUCCESS;
}
{
APR_BUCKET_INIT(b);
b->free = apr_bucket_free;
b->length = 0;
b->start = 0;
b->type = &ap_rl_bucket_type_end;
return b;
}
{
APR_BUCKET_INIT(b);
b->free = apr_bucket_free;
b->length = 0;
b->start = 0;
b->type = &ap_rl_bucket_type_start;
return b;
}
};
};
{
/* run after mod_deflate etc etc, but not at connection level, ie, mod_ssl. */
}
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command apr_table_t */
};