File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 72
72
#define umask _umask
73
73
typedef int mode_t ;
74
74
#else
75
+ #include < sys/resource.h> // getrlimit, setrlimit
75
76
#include < unistd.h> // setuid, getuid
76
77
#endif
77
78
@@ -3103,6 +3104,28 @@ void Init(int* argc,
3103
3104
node_isolate = Isolate::GetCurrent ();
3104
3105
3105
3106
#ifdef __POSIX__
3107
+ // Raise the open file descriptor limit.
3108
+ {
3109
+ struct rlimit lim;
3110
+ if (getrlimit (RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max ) {
3111
+ // Do a binary search for the limit.
3112
+ rlim_t min = lim.rlim_cur ;
3113
+ rlim_t max = 1 << 20 ;
3114
+ // But if there's a defined upper bound, don't search, just set it.
3115
+ if (lim.rlim_max != RLIM_INFINITY) {
3116
+ min = lim.rlim_max ;
3117
+ max = lim.rlim_max ;
3118
+ }
3119
+ do {
3120
+ lim.rlim_cur = min + (max - min) / 2 ;
3121
+ if (setrlimit (RLIMIT_NOFILE, &lim)) {
3122
+ max = lim.rlim_cur ;
3123
+ } else {
3124
+ min = lim.rlim_cur ;
3125
+ }
3126
+ } while (min + 1 < max);
3127
+ }
3128
+ }
3106
3129
// Ignore SIGPIPE
3107
3130
RegisterSignalHandler (SIGPIPE, SIG_IGN);
3108
3131
RegisterSignalHandler (SIGINT, SignalExit);
You can’t perform that action at this time.
0 commit comments