mirror of https://github.com/Icinga/icinga2.git
Improved buffering behavior.
This commit is contained in:
parent
4bd2adc4f9
commit
221bbe9a07
|
@ -34,15 +34,27 @@ int TCPClient::ReadableEventHandler(EventArgs::RefType ea)
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = recv(GetFD(), buffer, sizeof(buffer), 0);
|
while (true) {
|
||||||
|
rc = recv(GetFD(), buffer, sizeof(buffer), 0);
|
||||||
|
|
||||||
if (rc <= 0) {
|
#ifdef _WIN32
|
||||||
Close();
|
if (rc < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
|
||||||
return 0;
|
#else /* _WIN32 */
|
||||||
|
if (rc < 0 && errno == EAGAIN)
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (rc <= 0) {
|
||||||
|
Close();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_RecvQueue->Write(buffer, rc);
|
||||||
|
|
||||||
|
if (m_RecvQueue->GetSize() > 1024 * 1024)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_RecvQueue->Write(buffer, rc);
|
|
||||||
|
|
||||||
EventArgs::RefType dea = new_object<EventArgs>();
|
EventArgs::RefType dea = new_object<EventArgs>();
|
||||||
dea->Source = shared_from_this();
|
dea->Source = shared_from_this();
|
||||||
OnDataAvailable(dea);
|
OnDataAvailable(dea);
|
||||||
|
|
Loading…
Reference in New Issue