@@ -744,10 +744,17 @@ arg = arg; } static int filed_sockettimeout_thread_init(void) { pthread_t thread_id; + + pthread_create(&thread_id, NULL, filed_sockettimeout_thread, NULL); + + return(0); +} + +static int filed_sockettimeout_init(void) { long maxfd, idx; maxfd = sysconf(_SC_OPEN_MAX); if (maxfd <= 0) { maxfd = 4096; @@ -761,18 +768,15 @@ for (idx = 0; idx < maxfd; idx++) { filed_sockettimeout_sockstatus[idx].valid = false; } filed_sockettimeout_sockstatus_length = maxfd; - filed_sockettimeout_devnull_fd = open("/dev/null", O_RDWR); if (filed_sockettimeout_devnull_fd < 0) { return(-1); } - pthread_create(&thread_id, NULL, filed_sockettimeout_thread, NULL); - return(0); } #endif /* Format time per RFC2616 */ @@ -1755,10 +1759,18 @@ if (fd < 0) { perror("filed_listen"); return(1); } + + /* Initialize timeout structures */ + init_ret = filed_sockettimeout_init(); + if (init_ret != 0) { + perror("filed_sockettimeout_init"); + + return(8); + } /* Become a daemon */ if (daemon_enabled) { init_ret = filed_daemonize(); if (init_ret != 0) { @@ -1814,11 +1826,11 @@ /* Create socket termination thread */ init_ret = filed_sockettimeout_thread_init(); if (init_ret != 0) { perror("filed_sockettimeout_thread_init"); - return(6); + return(7); } /* Create worker threads */ init_ret = filed_worker_threads_init(fd, thread_count, &thread_options); if (init_ret != 0) {