aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_httpd.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-03-18 13:51:23 +0000
committerGravatar Sadie Powell2020-03-18 13:51:23 +0000
commitb9acde9aaf0ddae8b821b21821724adcdbea9359 (patch)
tree7c76b8988dd9e31596ae2b114b15a762561e063d /src/modules/m_httpd.cpp
parentRemove support for 0/1 in getBool. (diff)
parentAllow commands to override ERR_{NEEDSMOREPARAMS,NOTREGISTERED}. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_httpd.cpp')
-rw-r--r--src/modules/m_httpd.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index 5bf7d8bdc..06bdb1ae7 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -81,7 +81,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
{
if (!messagecomplete)
{
- AddToCull();
+ Close();
return false;
}
@@ -212,7 +212,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
// IOHook may have errored
if (!getError().empty())
{
- AddToCull();
+ Close();
return;
}
}
@@ -227,9 +227,19 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
sockets.erase(this);
}
+ void Close() override
+ {
+ if (waitingcull || !HasFd())
+ return;
+
+ waitingcull = true;
+ BufferedSocket::Close();
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
+
void OnError(BufferedSocketError) override
{
- AddToCull();
+ Close();
}
void SendHTTPError(unsigned int response)
@@ -298,7 +308,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
{
SendHeaders(s.length(), response, *hheaders);
WriteData(s);
- Close(true);
+ BufferedSocket::Close(true);
}
void Page(std::stringstream* n, unsigned int response, HTTPHeaders* hheaders)
@@ -306,16 +316,6 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
Page(n->str(), response, hheaders);
}
- void AddToCull()
- {
- if (waitingcull)
- return;
-
- waitingcull = true;
- Close();
- ServerInstance->GlobalCulls.AddItem(this);
- }
-
bool ParseURI(const std::string& uristr, HTTPRequestURI& out)
{
http_parser_url_init(&url);
@@ -422,7 +422,7 @@ class ModuleHttpServer : public Module
for (insp::intrusive_list<HttpServerSocket>::const_iterator i = sockets.begin(); i != sockets.end(); ++i)
{
HttpServerSocket* sock = *i;
- sock->AddToCull();
+ sock->Close();
}
return Module::cull();
}