Skip to content

Commit 745228b

Browse files
committed
Make %k work as it should. No regression noted in perl
test framework. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@720250 13f79535-47bb-0310-9956-ffa450edef68
1 parent 41eff67 commit 745228b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

modules/http/http_protocol.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ static int is_mpm_running(void)
176176
AP_DECLARE(int) ap_set_keepalive(request_rec *r)
177177
{
178178
int ka_sent = 0;
179+
int left = r->server->keep_alive_max - r->connection->keepalives;
179180
int wimpy = ap_find_token(r->pool,
180181
apr_table_get(r->headers_out, "Connection"),
181182
"close");
@@ -221,7 +222,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
221222
&& r->server->keep_alive
222223
&& (r->server->keep_alive_timeout > 0)
223224
&& ((r->server->keep_alive_max == 0)
224-
|| (r->server->keep_alive_max > r->connection->keepalives))
225+
|| (left > 0))
225226
&& !ap_status_drops_connection(r->status)
226227
&& !wimpy
227228
&& !ap_find_token(r->pool, conn, "close")
@@ -230,7 +231,6 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
230231
&& ((ka_sent = ap_find_token(r->pool, conn, "keep-alive"))
231232
|| (r->proto_num >= HTTP_VERSION(1,1)))
232233
&& is_mpm_running()) {
233-
int left = r->server->keep_alive_max - r->connection->keepalives;
234234

235235
r->connection->keepalive = AP_CONN_KEEPALIVE;
236236
r->connection->keepalives++;
@@ -266,6 +266,16 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
266266
apr_table_mergen(r->headers_out, "Connection", "close");
267267
}
268268

269+
/*
270+
* If we had previously been a keepalive connection and this
271+
* is the last one, then bump up the number of keepalives
272+
* we've had
273+
*/
274+
if ((r->connection->keepalive != AP_CONN_CLOSE)
275+
&& r->server->keep_alive_max
276+
&& !left) {
277+
r->connection->keepalives++;
278+
}
269279
r->connection->keepalive = AP_CONN_CLOSE;
270280

271281
return 0;

modules/loggers/mod_log_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ static const char *log_connection_status(request_rec *r, char *a)
697697

698698
static const char *log_requests_on_connection(request_rec *r, char *a)
699699
{
700-
return apr_itoa(r->pool, r->connection->keepalives);
700+
int num = r->connection->keepalives ? r->connection->keepalives - 1 : 0;
701+
return apr_itoa(r->pool, num);
701702
}
702703

703704
/*****************************************************************

0 commit comments

Comments
 (0)