summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sockets.h2
-rw-r--r--modules/webcpanel/template_fileserver.cpp11
-rw-r--r--src/socket_transport.cpp2
3 files changed, 10 insertions, 5 deletions
diff --git a/include/sockets.h b/include/sockets.h
index 744f1a23e..0dfa5d9d0 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -347,7 +347,7 @@ class CoreExport BinarySocket : public virtual Socket
/** Write data to the socket
* @param buffer The data to write
- * @param l The length of the data
+ * @param l The length of the data; if 0 then this function returns without doing anything
*/
virtual void Write(const char *buffer, size_t l);
void Write(const char *message, ...);
diff --git a/modules/webcpanel/template_fileserver.cpp b/modules/webcpanel/template_fileserver.cpp
index d4e5ec7e4..dc950b330 100644
--- a/modules/webcpanel/template_fileserver.cpp
+++ b/modules/webcpanel/template_fileserver.cpp
@@ -220,8 +220,11 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
Log() << "Invalid INCLUDE in web template " << this->file_name;
else
{
- reply.Write(finished); // Write out what we have currently so we insert this files contents here
- finished.clear();
+ if (!finished.empty())
+ {
+ reply.Write(finished); // Write out what we have currently so we insert this files contents here
+ finished.clear();
+ }
TemplateFileServer tfs(tokens[1]);
tfs.Serve(server, page_name, client, message, reply, r);
@@ -255,7 +258,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
}
}
- reply.Write(finished);
- return;
+ if (!finished.empty())
+ reply.Write(finished);
}
diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp
index 6293ea385..1476d0662 100644
--- a/src/socket_transport.cpp
+++ b/src/socket_transport.cpp
@@ -167,6 +167,8 @@ bool BinarySocket::ProcessWrite()
void BinarySocket::Write(const char *buffer, size_t l)
{
+ if (l == 0)
+ return;
this->write_buffer.push_back(new DataBlock(buffer, l));
SocketEngine::Change(this, true, SF_WRITABLE);
}