MCPcopy Create free account
hub / github.com/ElementsProject/elements / RaiseFileDescriptorLimit

Function RaiseFileDescriptorLimit

src/util/system.cpp:1208–1225  ·  view source on GitHub ↗

* this function tries to raise the file descriptor limit to the requested number. * It returns the actual file descriptor limit (which may be more or less than nMinFD) */

Source from the content-addressed store, hash-verified

1206 * It returns the actual file descriptor limit (which may be more or less than nMinFD)
1207 */
1208int RaiseFileDescriptorLimit(int nMinFD) {
1209#if defined(WIN32)
1210 return 2048;
1211#else
1212 struct rlimit limitFD;
1213 if (getrlimit(RLIMIT_NOFILE, &limitFD) != -1) {
1214 if (limitFD.rlim_cur < (rlim_t)nMinFD) {
1215 limitFD.rlim_cur = nMinFD;
1216 if (limitFD.rlim_cur > limitFD.rlim_max)
1217 limitFD.rlim_cur = limitFD.rlim_max;
1218 setrlimit(RLIMIT_NOFILE, &limitFD);
1219 getrlimit(RLIMIT_NOFILE, &limitFD);
1220 }
1221 return limitFD.rlim_cur;
1222 }
1223 return nMinFD; // getrlimit failed, assume it's fine
1224#endif
1225}
1226
1227/**
1228 * this function tries to make a particular range of a file allocated (corresponding to disk space)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected