summaryrefslogtreecommitdiff
path: root/src/modules/m_xmlsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_xmlsocket.cpp')
-rw-r--r--src/modules/m_xmlsocket.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/modules/m_xmlsocket.cpp b/src/modules/m_xmlsocket.cpp
index 8fcd72a52..5dc13c7f9 100644
--- a/src/modules/m_xmlsocket.cpp
+++ b/src/modules/m_xmlsocket.cpp
@@ -141,6 +141,12 @@ class ModuleXMLSocket : public Module
else if (result < 1)
return 0;
+ /* XXX: The core is more than happy to split lines purely on an \n
+ * rather than a \r\n. This is good for us as it means that the size
+ * of data we are receiving is exactly the same as the size of data
+ * we asked for, and we dont need to re-implement our own socket
+ * buffering (See below)
+ */
for (int n = 0; n < result; n++)
if (buffer[n] == 0)
buffer[n] = '\n';
@@ -156,9 +162,16 @@ class ModuleXMLSocket : public Module
if (user == NULL)
return -1;
+ /* We want to alter the buffer, so we have to make a copy */
char tmpbuffer[count+1];
memcpy(&tmpbuffer, &buffer, count);
+ /* XXX: This will actually generate lines "looking\0\0like\0\0this"
+ * rather than lines "looking\0like\0this". This shouldnt be a problem
+ * to the client, but it saves us a TON of processing and the need
+ * to re-implement socket buffering, as the data we are sending is
+ * exactly the same length as the data we are receiving.
+ */
for (int n = 0; n < count; n++)
if ((tmpbuffer[n] == '\r') || (tmpbuffer[n] == '\n'))
tmpbuffer[n] = 0;