blob: 6febf982ac8570676e825d5dbec248c2d4660ab1 [file] [log] [blame]
veeve01d187c2008-02-26 05:12:08 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
7#include <sys/time.h>
8#include <sys/resource.h>
9#include <unistd.h>
10
11namespace facebook { namespace thrift { namespace server {
12
13int increase_max_fds(int max_fds=(1<<24)) {
14 struct rlimit fdmaxrl;
15
16 for(fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
17 max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
18 fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
19 max_fds /= 2;
20 }
21
22 return fdmaxrl.rlim_cur;
23}
24
25}}} // facebook::thrift::server