1 ------------------------------------------------------------
3 revision-id: squid3@treenet.co.nz-20170529131555-kut221f3geb3aczf
4 parent: squid3@treenet.co.nz-20170529125748-qt7yhdloygl4xosg
5 fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4653
6 author: Christos Tsantilas <chtsanti@users.sourceforge.net>
7 committer: Amos Jeffries <squid3@treenet.co.nz>
9 timestamp: Tue 2017-05-30 01:15:55 +1200
11 Bug 4653: %st lies about tunneled traffic volumes
13 Squid-3.5 counts only the "CONNECT ..." header size for %>st and does not
14 count the "HTTP/1.1 200" response header for the %<st.
16 This is a Measurement Factory project
17 ------------------------------------------------------------
18 # Bazaar merge directive format 2 (Bazaar 0.90)
19 # revision_id: squid3@treenet.co.nz-20170529131555-kut221f3geb3aczf
20 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
21 # testament_sha1: dd5783b425c7c7125303a1bd1a5685bc28011754
22 # timestamp: 2017-05-29 13:51:09 +0000
23 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
24 # base_revision_id: squid3@treenet.co.nz-20170529125748-\
28 === modified file 'src/client_side.cc'
29 --- src/client_side.cc 2017-03-31 00:51:52 +0000
30 +++ src/client_side.cc 2017-05-29 13:15:55 +0000
32 // in.buf still has the "CONNECT ..." request data, reset it to SSL hello message
33 connState->in.buf.append(rbuf.content(), rbuf.contentSize());
34 ClientHttpRequest *http = context->http;
35 - tunnelStart(http, &http->out.size, &http->al->http.code, http->al);
41 === modified file 'src/client_side_reply.cc'
42 --- src/client_side_reply.cc 2017-01-01 00:16:45 +0000
43 +++ src/client_side_reply.cc 2017-05-29 13:15:55 +0000
45 if (curReply->content_length < 0)
48 - int64_t expectedLength = curReply->content_length + http->out.headers_sz;
49 + uint64_t expectedLength = curReply->content_length + http->out.headers_sz;
51 if (http->out.size < expectedLength)
54 === modified file 'src/client_side_request.cc'
55 --- src/client_side_request.cc 2017-05-29 07:10:37 +0000
56 +++ src/client_side_request.cc 2017-05-29 13:15:55 +0000
60 getConn()->stopReading(); // tunnels read for themselves
61 - tunnelStart(this, &out.size, &al->http.code, al);
67 === modified file 'src/client_side_request.h'
68 --- src/client_side_request.h 2017-01-23 02:05:46 +0000
69 +++ src/client_side_request.h 2017-05-29 13:15:55 +0000
80 void clientAccessCheck(ClientHttpRequest *);
82 /* ones that should be elsewhere */
83 -void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntry::Pointer &al);
84 +void tunnelStart(ClientHttpRequest *);
87 #include "client_side_request.cci"
89 === modified file 'src/tests/stub_tunnel.cc'
90 --- src/tests/stub_tunnel.cc 2017-01-01 00:16:45 +0000
91 +++ src/tests/stub_tunnel.cc 2017-05-29 13:15:55 +0000
94 class ClientHttpRequest;
96 -void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntryPointer &al) STUB
97 +void tunnelStart(ClientHttpRequest *) STUB
99 void switchToTunnel(HttpRequest *request, Comm::ConnectionPointer &clientConn, Comm::ConnectionPointer &srvConn) STUB
102 === modified file 'src/tunnel.cc'
103 --- src/tunnel.cc 2017-05-29 12:57:48 +0000
104 +++ src/tunnel.cc 2017-05-29 13:15:55 +0000
108 AsyncCall::Pointer writer; ///< pending Comm::Write callback
109 - int64_t *size_ptr; /* pointer to size in an ConnStateData for logging */
110 + uint64_t *size_ptr; /* pointer to size in an ConnStateData for logging */
112 Comm::ConnectionPointer conn; ///< The currently connected connection.
113 uint8_t delayedLoops; ///< how many times a read on this connection has been postponed.
118 + if (ClientHttpRequest *http = tunnelState->http.get()) {
119 + http->out.headers_sz += size;
120 + http->out.size += size;
123 tunnelStartShoveling(tunnelState);
130 -tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr, const AccessLogEntryPointer &al)
131 +tunnelStart(ClientHttpRequest * http)
134 /* Create state structure. */
135 @@ -1021,7 +1026,7 @@
136 if (ch.fastCheck() == ACCESS_DENIED) {
137 debugs(26, 4, HERE << "MISS access forbidden.");
138 err = new ErrorState(ERR_FORWARDING_DENIED, Http::scForbidden, request);
139 - *status_ptr = Http::scForbidden;
140 + http->al->http.code = Http::scForbidden;
141 errorSend(http->getConn()->clientConnection, err);
144 @@ -1037,12 +1042,13 @@
146 tunnelState->url = xstrdup(url);
147 tunnelState->request = request;
148 - tunnelState->server.size_ptr = size_ptr;
149 - tunnelState->status_ptr = status_ptr;
150 + tunnelState->server.size_ptr = &http->out.size;
151 + tunnelState->client.size_ptr = &http->al->http.clientRequestSz.payloadData;
152 + tunnelState->status_ptr = &http->al->http.code;
153 tunnelState->logTag_ptr = &http->logType;
154 tunnelState->client.conn = http->getConn()->clientConnection;
155 tunnelState->http = http;
156 - tunnelState->al = al;
157 + tunnelState->al = http->al ;
158 tunnelState->started = squid_curtime;
160 comm_add_close_handler(tunnelState->client.conn->fd,
161 @@ -1053,7 +1059,7 @@
162 CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
163 commSetConnTimeout(tunnelState->client.conn, Config.Timeout.lifetime, timeoutCall);
165 - peerSelect(&(tunnelState->serverDestinations), request, al,
166 + peerSelect(&(tunnelState->serverDestinations), request, tunnelState->al,
168 tunnelPeerSelectComplete,
170 @@ -1226,6 +1232,10 @@
171 if (context != NULL && context->http != NULL) {
172 tunnelState->logTag_ptr = &context->http->logType;
173 tunnelState->server.size_ptr = &context->http->out.size;
174 + if (context->http->al != NULL) {
175 + tunnelState->al = context->http->al;
176 + tunnelState->client.size_ptr = &context->http->al->http.clientRequestSz.payloadData;
180 /* no point using the delayIsNoDelay stuff since tunnel is nice and simple */