]> git.ipfire.org Git - thirdparty/squid.git/blob - src/Pipeline.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / Pipeline.cc
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 /*
10 * DEBUG: section 33 Client Request Pipeline
11 */
12 #include "squid.h"
13 #include "anyp/PortCfg.h"
14 #include "client_side.h"
15 #include "Debug.h"
16 #include "Pipeline.h"
17
18 void
19 Pipeline::add(const ClientSocketContextPointer &c)
20 {
21 requests.push_back(c);
22 ++nrequests;
23 debugs(33, 3, "Pipeline " << (void*)this << " add request " << nrequests << ' ' << c);
24 }
25
26 ClientSocketContextPointer
27 Pipeline::front() const
28 {
29 if (requests.empty()) {
30 debugs(33, 3, "Pipeline " << (void*)this << " empty");
31 return ClientSocketContextPointer();
32 }
33
34 debugs(33, 3, "Pipeline " << (void*)this << " front " << requests.front());
35 return requests.front();
36 }
37
38 void
39 Pipeline::terminateAll(int xerrno)
40 {
41 while (!requests.empty()) {
42 ClientSocketContextPointer context = requests.front();
43 debugs(33, 3, "Pipeline " << (void*)this << " notify(" << xerrno << ") " << context);
44 context->noteIoError(xerrno);
45 context->finished(); // cleanup and self-deregister
46 assert(context != requests.front());
47 }
48 }
49
50 void
51 Pipeline::popMe(const ClientSocketContextPointer &which)
52 {
53 if (requests.empty())
54 return;
55
56 debugs(33, 3, "Pipeline " << (void*)this << " drop " << requests.front());
57 // in reality there may be multiple contexts doing processing in parallel.
58 // XXX: pipeline still assumes HTTP/1 FIFO semantics are obeyed.
59 assert(which == requests.front());
60 requests.pop_front();
61 }
62