veeve | 01d187c | 2008-02-26 05:12:08 +0000 | [diff] [blame^] | 1 | // 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 | |
| 11 | namespace facebook { namespace thrift { namespace server { |
| 12 | |
| 13 | int 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 |