src/transport/TSocketPool.cpp \
src/transport/TServerSocket.cpp \
src/transport/TTransportUtils.cpp \
+ src/server/TServer.cpp \
src/server/TSimpleServer.cpp \
src/server/TThreadPoolServer.cpp \
src/server/TThreadedServer.cpp \
--- /dev/null
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+namespace facebook { namespace thrift { namespace server {
+
+int increase_max_fds(int max_fds=(1<<24)) {
+ struct rlimit fdmaxrl;
+
+ for(fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
+ max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
+ fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
+ max_fds /= 2;
+ }
+
+ return fdmaxrl.rlim_cur;
+}
+
+}}} // facebook::thrift::server
};
+/**
+ * Helper function to increase the max file descriptors limit
+ * for the current process and all of its children.
+ * By default, tries to increase it to as much as 2^24.
+ */
+ int increase_max_fds(int max_fds=(1<<24));
+
+
}}} // facebook::thrift::server
#endif // #ifndef _THRIFT_SERVER_TSERVER_H_