]> git.ipfire.org Git - thirdparty/squid.git/blame - src/Pipeline.h
Revert wrong changes incorrectly added to r14477
[thirdparty/squid.git] / src / Pipeline.h
CommitLineData
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#ifndef SQUID_SRC_PIPELINE_H
10#define SQUID_SRC_PIPELINE_H
11
12#include "base/RefCount.h"
13
14#include <list>
15
16class ClientSocketContext;
17typedef RefCount<ClientSocketContext> ClientSocketContextPointer;
18
19/**
1fad8490 20 * A queue of transactions awaiting completion.
8e64903f 21 *
1fad8490 22 * Transactions in the queue may be fully processed, but not yet delivered,
8e64903f
AJ
23 * or only partially processed.
24 *
25 * - HTTP/1 pipelined requests can be processed out of order but
26 * responses MUST be written to the client in-order.
1fad8490
AJ
27 * The front() context is for the response writing transaction.
28 * The back context may still be reading a request payload/body.
29 * Other contexts are in deferred I/O state, but may be accumulating
30 * payload/body data to be written later.
8e64903f 31 *
1fad8490 32 * - HTTP/2 multiplexed streams can be processed and delivered in any order.
8e64903f
AJ
33 *
34 * For consistency we treat the pipeline as a FIFO queue in both cases.
35 */
36class Pipeline
37{
38 Pipeline(const Pipeline &) = delete;
39 Pipeline & operator =(const Pipeline &) = delete;
40
41public:
42 Pipeline() : nrequests(0) {}
8ced7106 43 ~Pipeline() = default;
8e64903f
AJ
44
45 /// register a new request context to the pipeline
46 void add(const ClientSocketContextPointer &);
47
48 /// get the first request context in the pipeline
49 ClientSocketContextPointer front() const;
50
51 /// how many requests are currently pipelined
52 size_t count() const {return requests.size();}
53
54 /// whether there are none or any requests currently pipelined
55 bool empty() const {return requests.empty();}
56
57 /// tell everybody about the err, and abort all waiting requests
58 void terminateAll(const int xerrno);
59
60 /// deregister the front request from the pipeline
1fad8490 61 void popMe(const ClientSocketContextPointer &);
8e64903f
AJ
62
63 /// Number of requests seen in this pipeline (so far).
64 /// Includes incomplete transactions.
65 uint32_t nrequests;
66
67private:
68 /// requests parsed from the connection but not yet completed.
69 std::list<ClientSocketContextPointer> requests;
70};
71
72#endif /* SQUID_SRC_PIPELINE_H */
73