From c271f30080d6bf5d8b66bb2b14fdefb19f9c51cb Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Sat, 11 Oct 2025 22:07:20 +0000 Subject: [PATCH 1/2] don't double count requests in same conn --- mod_vhost_limit.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mod_vhost_limit.cpp b/mod_vhost_limit.cpp index 950fbd5..ac6e62e 100644 --- a/mod_vhost_limit.cpp +++ b/mod_vhost_limit.cpp @@ -136,11 +136,16 @@ static int handle_r(request_rec *r) char *s = (char*) apr_pcalloc(pool, sizeof(char)*8); apr_snprintf(s,8,"%d",conf->sid); apr_table_t *table = r->connection->notes; - apr_table_setn(table,"sid", s ); - apr_atomic_add32(&data->counter,1); - - ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0 ,NULL, "%s: handling IN %s (%s) = %d", MOD_NAME, conf->name, s, data->counter); + const char *existing_sid = apr_table_get(table, "sid"); + if (existing_sid == NULL) { + apr_table_setn(table,"sid", s ); + apr_atomic_add32(&data->counter,1); + ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0 ,NULL, "%s: handling IN %s (%s) = %d", MOD_NAME, conf->name, s, data->counter); + } + else { + ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0 ,NULL, "%s: sid already exists = %d", MOD_NAME, conf->name, s); + } return DECLINED; } From e6537df23d11c220e5e42644df48b7f35c07eea9 Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Sat, 11 Oct 2025 22:07:48 +0000 Subject: [PATCH 2/2] deferring connections should be a warning --- mod_vhost_limit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod_vhost_limit.cpp b/mod_vhost_limit.cpp index ac6e62e..bab732e 100644 --- a/mod_vhost_limit.cpp +++ b/mod_vhost_limit.cpp @@ -129,7 +129,7 @@ static int handle_r(request_rec *r) if (data->counter >= conf->max_clients) { - ap_log_error(APLOG_MARK, APLOG_INFO, 0,NULL,"%s: Access to %s deferred, Max Clients %d exceeded (%d currently)",MOD_NAME, conf->name, conf->max_clients, data->counter); + ap_log_error(APLOG_MARK, APLOG_WARNING, 0,NULL,"%s: Access to %s deferred, Max Clients %d exceeded (%d currently)",MOD_NAME, conf->name, conf->max_clients, data->counter); return HTTP_SERVICE_UNAVAILABLE; }