mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
http: only read one HTTPRequest at a time per client
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#define BITCOIN_HTTPSERVER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -479,10 +478,9 @@ public:
|
||||
std::string m_recv_buffer{};
|
||||
|
||||
//! Requests from a client must be processed in the order in which
|
||||
//! they were received, blocking on a per-client basis. We won't
|
||||
//! process the next request in the queue if we are currently busy
|
||||
//! handling a previous request.
|
||||
std::deque<std::unique_ptr<HTTPRequest>> m_req_queue;
|
||||
//! they were received, blocking on a per-client basis. We read
|
||||
//! one request at a time from the socket buffer then pass it to a worker.
|
||||
std::unique_ptr<HTTPRequest> m_req;
|
||||
|
||||
//! Set to true by the I/O thread when a request is popped off
|
||||
//! and passed to a worker thread, reset to false by the worker thread.
|
||||
@@ -555,6 +553,12 @@ public:
|
||||
HTTPRemoteClient(const HTTPRemoteClient&) = delete;
|
||||
HTTPRemoteClient& operator=(const HTTPRemoteClient&) = delete;
|
||||
|
||||
//! Release any in-progress request. HTTPRequest holds a shared_ptr back to its
|
||||
//! HTTPRemoteClient to keep the client alive from a worker thread. If a request
|
||||
//! hasn't been moved to a worker yet it will prevent the client from destructing
|
||||
//! and never close the socket. Therefore this must be called when disconnecting.
|
||||
void ReleaseRequest() { m_req.reset(); }
|
||||
|
||||
/**
|
||||
* Try to read an HTTP request from the receive buffer.
|
||||
* @param[in] req A HTTPRequest to read into
|
||||
|
||||
Reference in New Issue
Block a user