]>
Commit | Line | Data |
---|---|---|
8e64903f | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors |
8e64903f AJ |
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" | |
22d80540 | 13 | #include "anyp/PortCfg.h" |
8e64903f AJ |
14 | #include "client_side.h" |
15 | #include "Debug.h" | |
8d664cb0 | 16 | #include "http/StreamContext.h" |
8e64903f AJ |
17 | #include "Pipeline.h" |
18 | ||
19 | void | |
8d664cb0 | 20 | Pipeline::add(const Http::StreamContextPointer &c) |
8e64903f AJ |
21 | { |
22 | requests.push_back(c); | |
23 | ++nrequests; | |
99039d37 | 24 | ++nactive; |
8e64903f AJ |
25 | debugs(33, 3, "Pipeline " << (void*)this << " add request " << nrequests << ' ' << c); |
26 | } | |
27 | ||
8d664cb0 | 28 | Http::StreamContextPointer |
8e64903f AJ |
29 | Pipeline::front() const |
30 | { | |
31 | if (requests.empty()) { | |
32 | debugs(33, 3, "Pipeline " << (void*)this << " empty"); | |
8d664cb0 | 33 | return Http::StreamContextPointer(); |
8e64903f AJ |
34 | } |
35 | ||
36 | debugs(33, 3, "Pipeline " << (void*)this << " front " << requests.front()); | |
37 | return requests.front(); | |
38 | } | |
39 | ||
40 | void | |
41 | Pipeline::terminateAll(int xerrno) | |
42 | { | |
43 | while (!requests.empty()) { | |
8d664cb0 | 44 | Http::StreamContextPointer context = requests.front(); |
8e64903f AJ |
45 | debugs(33, 3, "Pipeline " << (void*)this << " notify(" << xerrno << ") " << context); |
46 | context->noteIoError(xerrno); | |
d20f59e2 | 47 | context->finished(); // cleanup and self-deregister |
8e64903f AJ |
48 | assert(context != requests.front()); |
49 | } | |
50 | } | |
51 | ||
52 | void | |
99039d37 | 53 | Pipeline::popById(uint32_t which) |
8e64903f AJ |
54 | { |
55 | if (requests.empty()) | |
56 | return; | |
57 | ||
99039d37 AJ |
58 | debugs(33, 3, "Pipeline " << (void*)this << " drop id=" << which); |
59 | ||
60 | // find the context and clear its Pointer | |
61 | for (auto &&i : requests) { | |
62 | if (i->id == which) { | |
63 | i = nullptr; | |
64 | --nactive; | |
65 | break; | |
66 | } | |
67 | } | |
68 | ||
69 | // trim closed contexts from the list head (if any) | |
70 | while (!requests.empty() && !requests.front()) | |
71 | requests.pop_front(); | |
8e64903f AJ |
72 | } |
73 |