rendered paste bodyIndex: include/sockets/TcpSocket.h
===================================================================
--- include/sockets/TcpSocket.h (revision 5293)
+++ include/sockets/TcpSocket.h (working copy)
@@ -37,9 +37,12 @@
#endif
#include <string.h>
-
+#include "Log.h"
#define TCP_BUFSIZE_READ 16400
-#define TCP_OUTPUT_CAPACITY 1024000
+#define TCP_OUTPUT_CAPACITY 131072 //set 2^17 ,
+//Rognar
+//1024000 bytes - it's too large output buffer for mangos's purposes.
+//it was so large for WSAEWOULDBLOCK functionality
#ifdef SOCKETS_NAMESPACE
@@ -104,7 +107,13 @@
memcpy(_buf, buf, len);
}
size_t Space() {
- return TCP_OUTPUT_CAPACITY - _t;
+ if(TCP_OUTPUT_CAPACITY >= _t) //Rognar
+ return TCP_OUTPUT_CAPACITY - _t; //unsigned - unsigned.. danger, imho
+ else
+ {
+ sLog.outLag("\nWARNING: ASSERT(TCP_OUTPUT_CAPACITY >= _t)\n");
+ return 0;
+ }
}
void Add(const char *buf, size_t len) {
memcpy(_buf + _t, buf, len);
Index: src/sockets/TcpSocket.cpp
===================================================================
--- src/sockets/TcpSocket.cpp (revision 5293)
+++ src/sockets/TcpSocket.cpp (working copy)
@@ -769,8 +769,13 @@
OnDisconnect();
SetCloseAndDelete(true);
SetFlushBeforeClose(false);
- SetLost();
+ SetLost(); //Rognar
+ return -1; //Otherwise we will add unsent data to output buffer in TcpSocket.cpp:864
}
+ else if(Errno == WSAEWOULDBLOCK)
+ { //Rognar: it would be better to close connection..
+ sLog.outError("\n socket[%u] Assert(Errno != WSAEWOULDBLOCK) bad connection. Disconnect?\n", GetSocket());
+ }
return 0;
}
}
@@ -811,6 +816,11 @@
}
else
{
+ size_t _size = m_obuf.size();
+ if(_size > 1)
+ {
+ sLog.outLag("WARNING:Socket already have [%u] bytes reserved memory. Free size [%u]", (_size*TCP_OUTPUT_CAPACITY), space);
+ }
m_obuf_top = new OUTPUT;
m_obuf.push_back( m_obuf_top );
}