Overview
Comment: | Updated to set resource limits for number of open files at startup, if possible |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | ea36882e154878cc7f9299197d1eeef9c8370f0e |
User & Date: | rkeene on 2015-10-14 17:48:16 |
Other Links: | manifest | tags |
Context
2015-11-19
| ||
16:01 | Updated initializer to be explicitly unsigned check-in: f905360d64 user: rkeene tags: trunk | |
2015-10-14
| ||
17:48 | Updated to set resource limits for number of open files at startup, if possible check-in: ea36882e15 user: rkeene tags: trunk | |
17:47 | Updated to be more careful about closing files check-in: b357796ad5 user: rkeene tags: trunk | |
Changes
Modified appfsd.c from [6b6df68529] to [55077e4885].
17 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 20 * THE SOFTWARE. 21 21 */ 22 22 #define FUSE_USE_VERSION 26 23 23 24 +#include <sys/resource.h> 24 25 #include <sys/fsuid.h> 25 26 #include <sys/types.h> 27 +#include <sys/time.h> 26 28 #include <pthread.h> 27 29 #include <signal.h> 28 30 #include <limits.h> 29 31 #include <string.h> 30 32 #include <stdarg.h> 31 33 #include <stdlib.h> 32 34 #include <unistd.h> ................................................................................ 2167 2169 /* 2168 2170 * Entry point into this program. 2169 2171 */ 2170 2172 int main(int argc, char **argv) { 2171 2173 Tcl_Interp *test_interp; 2172 2174 char *test_interp_error; 2173 2175 struct fuse_args args = FUSE_ARGS_INIT(0, NULL); 2174 - int pthread_ret, aop_ret; 2176 + struct rlimit number_open_files; 2177 + int pthread_ret, aop_ret, rlimit_ret; 2175 2178 void *signal_ret; 2176 2179 char *argv0; 2180 + rlim_t number_open_files_max; 2177 2181 2178 2182 /* 2179 2183 * Skip passed program name 2180 2184 */ 2181 2185 if (argc == 0 || argv == NULL) { 2182 2186 return(1); 2183 2187 } ................................................................................ 2301 2305 } 2302 2306 2303 2307 Tcl_DeleteInterp(test_interp); 2304 2308 2305 2309 if (appfs_threaded_tcl) { 2306 2310 Tcl_FinalizeNotifier(NULL); 2307 2311 } 2312 + 2313 + /* 2314 + * Increase resource limits for number of open files 2315 + * to the maximum values, since we may be asked to 2316 + * hold open many files on behalf of many other processes 2317 + */ 2318 + number_open_files.rlim_cur = number_open_files.rlim_max = RLIM_INFINITY; 2319 + 2320 + rlimit_ret = setrlimit(RLIMIT_NOFILE, &number_open_files); 2321 + 2322 + if (rlimit_ret != 0) { 2323 + rlimit_ret = getrlimit(RLIMIT_NOFILE, &number_open_files); 2324 + if (rlimit_ret == 0) { 2325 + number_open_files_max = number_open_files.rlim_max; 2326 + 2327 + if (number_open_files_max < (1024 * 1024)) { 2328 + number_open_files.rlim_cur = number_open_files.rlim_max = 1024 * 1024; 2329 + 2330 + rlimit_ret = setrlimit(RLIMIT_NOFILE, &number_open_files); 2331 + } else { 2332 + number_open_files.rlim_cur = number_open_files.rlim_max; 2333 + } 2334 + 2335 + rlimit_ret = setrlimit(RLIMIT_NOFILE, &number_open_files); 2336 + 2337 + if (rlimit_ret != 0 && number_open_files.rlim_cur != number_open_files_max) { 2338 + number_open_files.rlim_cur = number_open_files.rlim_max = number_open_files_max; 2339 + 2340 + setrlimit(RLIMIT_NOFILE, &number_open_files); 2341 + } 2342 + } 2343 + } 2344 + 2308 2345 2309 2346 /* 2310 2347 * Enter the FUSE main loop -- this will process any arguments 2311 2348 * and start servicing requests. 2312 2349 */ 2313 2350 appfs_fuse_started = 1; 2314 2351 return(fuse_main(args.argc, args.argv, &appfs_operations, NULL)); 2315 2352 }