aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/httpserver.cpp')
-rw-r--r--src/httpserver.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 0a8e58ab67..45c049c3be 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -63,12 +63,11 @@ template <typename WorkItem>
class WorkQueue
{
private:
- /** Mutex protects entire object */
Mutex cs;
- std::condition_variable cond;
- std::deque<std::unique_ptr<WorkItem>> queue;
- bool running;
- size_t maxDepth;
+ std::condition_variable cond GUARDED_BY(cs);
+ std::deque<std::unique_ptr<WorkItem>> queue GUARDED_BY(cs);
+ bool running GUARDED_BY(cs);
+ const size_t maxDepth;
public:
explicit WorkQueue(size_t _maxDepth) : running(true),
@@ -262,7 +261,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
item.release(); /* if true, queue took ownership */
else {
LogPrintf("WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting\n");
- item->req->WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Work queue depth exceeded");
+ item->req->WriteReply(HTTP_SERVICE_UNAVAILABLE, "Work queue depth exceeded");
}
} else {
hreq->WriteReply(HTTP_NOT_FOUND);
@@ -290,8 +289,8 @@ static bool ThreadHTTP(struct event_base* base)
/** Bind HTTP server to specified addresses */
static bool HTTPBindAddresses(struct evhttp* http)
{
- int http_port = gArgs.GetArg("-rpcport", BaseParams().RPCPort());
- std::vector<std::pair<std::string, uint16_t> > endpoints;
+ uint16_t http_port{static_cast<uint16_t>(gArgs.GetArg("-rpcport", BaseParams().RPCPort()))};
+ std::vector<std::pair<std::string, uint16_t>> endpoints;
// Determine what addresses to bind to
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-rpcbind"))) { // Default to loopback if not allowing external IPs
@@ -305,7 +304,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
}
} else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address
for (const std::string& strRPCBind : gArgs.GetArgs("-rpcbind")) {
- int port = http_port;
+ uint16_t port{http_port};
std::string host;
SplitHostPort(strRPCBind, port, host);
endpoints.push_back(std::make_pair(host, port));