From 07bf18059d59db23ab8d7e56204b1b84a1e0c97f Mon Sep 17 00:00:00 2001 From: "Roy T. Fielding" Date: Mon, 12 May 2008 20:53:13 +0000 Subject: [PATCH] Don't stop sending a request if EAGAIN is returned, which will only happen if both the write and subsequent wait are returning EAGAIN, and count posted bytes correctly when the initial write of a request is not complete. PR 10038, 38861, 39679 Submitted by: Patrick McManus (in 2003) Stefan Fleiter (in 2006) and Davanum Srinivas (in 2006). Committed patch contains parts of all three, tweaked by Roy (2008). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@655637 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 8 ++++++++ support/ab.c | 25 +++++++------------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index 523f88ee37..f945e25300 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,14 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) ab: Don't stop sending a request if EAGAIN is returned, which + will only happen if both the write and subsequent wait are + returning EAGAIN, and count posted bytes correctly when the initial + write of a request is not complete. PR 10038, 38861, 39679 + [Patrick McManus , + Stefan Fleiter , + Davanum Srinivas, Roy T. Fielding] + *) ab: Overhaul stats collection and reporting to avoid integer truncation and time divisions within the test loop, retain native time resolution until output, remove unused data, diff --git a/support/ab.c b/support/ab.c index 438872b8aa..d74111e403 100644 --- a/support/ab.c +++ b/support/ab.c @@ -627,8 +627,8 @@ static void write_request(struct connection * c) if (c->rwrite == 0) { apr_socket_timeout_set(c->aprsock, 0); c->connect = tnow; - c->rwrite = reqlen; c->rwrote = 0; + c->rwrite = reqlen; if (posting) c->rwrite += postlen; } @@ -655,28 +655,17 @@ static void write_request(struct connection * c) #endif e = apr_socket_send(c->aprsock, request + c->rwrote, &l); - /* - * Bail early on the most common case - */ - if (l == c->rwrite) - break; - - if (e != APR_SUCCESS) { - /* - * Let's hope this traps EWOULDBLOCK too ! - */ - if (!APR_STATUS_IS_EAGAIN(e)) { - epipe++; - printf("Send request failed!\n"); - close_connection(c); - } + if (e != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(e)) { + epipe++; + printf("Send request failed!\n"); + close_connection(c); return; } + totalposted += l; c->rwrote += l; c->rwrite -= l; - } while (1); + } while (c->rwrite); - totalposted += c->rwrite; c->state = STATE_READ; c->endwrite = lasttime = apr_time_now(); { -- 2.40.0