THRIFT-1337 support maximum frame size in TNonblockingServer
Patch: Dave Watson
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1213052 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h
index 9eedcee..e5d3311 100644
--- a/lib/cpp/src/server/TNonblockingServer.h
+++ b/lib/cpp/src/server/TNonblockingServer.h
@@ -121,6 +121,9 @@
/// Default limit on size of idle connection pool
static const size_t CONNECTION_STACK_LIMIT = 1024;
+ /// Default limit on frame size
+ static const int MAX_FRAME_SIZE = 256 * 1024 * 1024;
+
/// Default limit on total number of connected sockets
static const int MAX_CONNECTIONS = INT_MAX;
@@ -190,6 +193,9 @@
/// Limit for number of open connections
size_t maxConnections_;
+ /// Limit for frame size
+ size_t maxFrameSize_;
+
/// Time in milliseconds before an unperformed task expires (0 == infinite).
int64_t taskExpireTime_;
@@ -271,6 +277,7 @@
connectionStackLimit_ = CONNECTION_STACK_LIMIT;
maxActiveProcessors_ = MAX_ACTIVE_PROCESSORS;
maxConnections_ = MAX_CONNECTIONS;
+ maxFrameSize_ = MAX_FRAME_SIZE;
taskExpireTime_ = 0;
overloadHysteresis_ = 0.8;
overloadAction_ = T_OVERLOAD_NO_ACTION;
@@ -519,6 +526,27 @@
}
/**
+ * Get the maximum allowed frame size.
+ *
+ * If a client tries to send a message larger than this limit,
+ * its connection will be closed.
+ *
+ * @return Maxium frame size, in bytes.
+ */
+ size_t getMaxFrameSize() const {
+ return maxFrameSize_;
+ }
+
+ /**
+ * Set the maximum allowed frame size.
+ *
+ * @param maxFrameSize The new maximum frame size.
+ */
+ void setMaxFrameSize(size_t maxFrameSize) {
+ maxFrameSize_ = maxFrameSize;
+ }
+
+ /**
* Get fraction of maximum limits before an overload condition is cleared.
*
* @return hysteresis fraction