Module: check_mk
Branch: master
Commit: b66752185b1f7d844fed519679473fc9a597705d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b66752185b1f7d…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Dec 17 09:19:18 2015 +0100
windows agent: the target packet size for the socket buffers is now configurable
---
agents/windows/OutputProxy.cc | 10 ++++++----
agents/windows/OutputProxy.h | 13 +++++++++----
agents/windows/check_mk_agent.cc | 7 ++++++-
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/agents/windows/OutputProxy.cc b/agents/windows/OutputProxy.cc
index a87d20e..963f191 100644
--- a/agents/windows/OutputProxy.cc
+++ b/agents/windows/OutputProxy.cc
@@ -55,8 +55,9 @@ void FileOutputProxy::flush() {
}
-BufferedSocketProxy::BufferedSocketProxy(SOCKET socket, size_t buffer_size)
+BufferedSocketProxy::BufferedSocketProxy(SOCKET socket, size_t buffer_size, size_t
collect_size)
: _socket(socket)
+ , _collect_size(collect_size)
{
_buffer.resize(buffer_size);
}
@@ -92,7 +93,7 @@ void BufferedSocketProxy::output(const char *format, ...)
// We do not send out the data immediately
// This would lead to many small tcp packages
- if (_length > MIN_OUTPUT_SIZE) {
+ if (_length > _collect_size) {
flushInt();
}
}
@@ -104,7 +105,7 @@ void BufferedSocketProxy::writeBinary(const char *buffer, size_t
size)
memcpy(&_buffer[0] + _length, buffer, size);
_length += size;
- if (_length > MIN_OUTPUT_SIZE) {
+ if (_length > _collect_size) {
flushInt();
}
}
@@ -175,7 +176,7 @@ bool BufferedSocketProxy::flushInt()
EncryptingBufferedSocketProxy::EncryptingBufferedSocketProxy(SOCKET socket,
- const std::string &passphrase, size_t buffer_size)
+ const std::string &passphrase, size_t buffer_size, size_t collect_size)
: BufferedSocketProxy(socket, buffer_size)
, _crypto(passphrase)
{
@@ -187,6 +188,7 @@ EncryptingBufferedSocketProxy::EncryptingBufferedSocketProxy(SOCKET
socket,
void EncryptingBufferedSocketProxy::output(const char *format, ...)
{
+
va_list ap;
va_start(ap, format);
diff --git a/agents/windows/OutputProxy.h b/agents/windows/OutputProxy.h
index 47251ca..4f2a2da 100644
--- a/agents/windows/OutputProxy.h
+++ b/agents/windows/OutputProxy.h
@@ -59,6 +59,7 @@ class BufferedSocketProxy : public OutputProxy {
SOCKET _socket;
std::vector<char> _buffer;
size_t _length { 0 };
+ size_t _collect_size;
protected:
@@ -67,12 +68,13 @@ protected:
private:
- static const size_t DEFAULT_BUFFER_SIZE = 16384L;
- static const size_t MIN_OUTPUT_SIZE = 1300L; // MTU for Ethernet is 1500 bytes
+ static const size_t DEFAULT_BUFFER_SIZE = 16384L;
+ static const size_t DEFAULT_COLLECT_SIZE = 1300L;
public:
- BufferedSocketProxy(SOCKET socket, size_t buffer_size = DEFAULT_BUFFER_SIZE);
+ BufferedSocketProxy(SOCKET socket, size_t buffer_size = DEFAULT_BUFFER_SIZE,
+ size_t collect_size = DEFAULT_COLLECT_SIZE);
void setSocket(SOCKET socket);
@@ -100,6 +102,8 @@ class EncryptingBufferedSocketProxy : public BufferedSocketProxy {
private:
static const size_t DEFAULT_BUFFER_SIZE = 16384L;
+ static const size_t DEFAULT_COLLECT_SIZE = 1300L;
+
std::vector<char> _plain;
size_t _blockSize;
size_t _written;
@@ -107,7 +111,8 @@ private:
public:
EncryptingBufferedSocketProxy(SOCKET socket, const std::string &passphrase,
- size_t buffer_size = DEFAULT_BUFFER_SIZE);
+ size_t buffer_size = DEFAULT_BUFFER_SIZE,
+ size_t collect_size = DEFAULT_COLLECT_SIZE);
virtual void output(const char *format, ...) override;
// writeBinary is NOT overridden so calls to it are not encrypted!
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 6d773d0..5fca2d5 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -3139,7 +3139,12 @@ DWORD WINAPI realtime_check_func(void *data_in)
std::string current_ip;
SOCKET current_socket = INVALID_SOCKET;
- EncryptingBufferedSocketProxy out(INVALID_SOCKET, g_config->passphrase());
+ // maximum udp datagram size - 1000
+ // this has no effect, my datagrams still get split at 1500bytes by
+ // windows. :(
+ static const size_t TARGET_DATAGRAM_SIZE = 65507L - 1000L;
+ EncryptingBufferedSocketProxy out(INVALID_SOCKET, g_config->passphrase(),
+ TARGET_DATAGRAM_SIZE);
time_t before = time(NULL);
while (!data->terminate) {
// wait for 1 second minus the time the last iteration took