summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-08-26 09:43:23 +0100
committerPeter Powell <petpow@saberuk.com>2019-08-26 10:45:11 +0100
commit78f9c572119aef08c9115ad61caa41e82b41c98a (patch)
tree9afe31a6837f10e6ed55d19b02f1f1988ffec5f4
parenta1b436b6e8dce10b8a3265b469125c7ed1311278 (diff)
Fix the haproxy module losing initial data in some circumstances.
-rw-r--r--src/modules/m_haproxy.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/modules/m_haproxy.cpp b/src/modules/m_haproxy.cpp
index 4d0e52514..19aac8ebd 100644
--- a/src/modules/m_haproxy.cpp
+++ b/src/modules/m_haproxy.cpp
@@ -219,7 +219,16 @@ class HAProxyHook : public IOHookMiddle
return true;
}
- int ReadProxyAddress(StreamSocket* sock)
+ int ReadData(std::string& destrecvq)
+ {
+ // Once connected we handle no special data.
+ std::string& recvq = GetRecvQ();
+ destrecvq.append(recvq);
+ recvq.clear();
+ return 1;
+ }
+
+ int ReadProxyAddress(StreamSocket* sock, std::string& destrecvq)
{
// Block until we have the entire address.
std::string& recvq = GetRecvQ();
@@ -276,14 +285,15 @@ class HAProxyHook : public IOHookMiddle
// Erase the processed proxy information from the receive queue.
recvq.erase(0, address_length);
+ break;
}
// We're done!
state = HPS_CONNECTED;
- return 1;
+ return ReadData(destrecvq);
}
- int ReadProxyHeader(StreamSocket* sock)
+ int ReadProxyHeader(StreamSocket* sock, std::string& destrecvq)
{
// Block until we have a header.
std::string& recvq = GetRecvQ();
@@ -359,7 +369,7 @@ class HAProxyHook : public IOHookMiddle
}
state = HPS_WAITING_FOR_ADDRESS;
- return ReadProxyAddress(sock);
+ return ReadProxyAddress(sock, destrecvq);
}
public:
@@ -384,16 +394,13 @@ class HAProxyHook : public IOHookMiddle
switch (state)
{
case HPS_WAITING_FOR_HEADER:
- return ReadProxyHeader(sock);
+ return ReadProxyHeader(sock, destrecvq);
case HPS_WAITING_FOR_ADDRESS:
- return ReadProxyAddress(sock);
+ return ReadProxyAddress(sock, destrecvq);
case HPS_CONNECTED:
- std::string& recvq = GetRecvQ();
- destrecvq.append(recvq);
- recvq.clear();
- return 1;
+ return ReadData(destrecvq);
}
// We should never reach this point.