Deleted Added
sdiff udiff text old ( 266114 ) new ( 276605 )
full compact
1/*
2 * daemon/unbound.c - main program for unbound DNS resolver daemon.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 70 unchanged lines hidden (view full) ---

79
80#ifdef USE_MINI_EVENT
81# ifdef USE_WINSOCK
82# include "util/winsock_event.h"
83# else
84# include "util/mini_event.h"
85# endif
86#else
87# ifdef HAVE_EVENT_H
88# include <event.h>
89# else
90# include "event2/event.h"
91# include "event2/event_struct.h"
92# include "event2/event_compat.h"
93# endif
94#endif
95
96#ifdef UB_ON_WINDOWS
97# include "winrc/win_svc.h"
98#endif
99
100#ifdef HAVE_NSS
101/* nss3 */

--- 162 unchanged lines hidden (view full) ---

264 return;
265 if((size_t)rlim.rlim_cur < total) {
266 avail = (size_t)rlim.rlim_cur;
267 rlim.rlim_cur = (rlim_t)(total + 10);
268 rlim.rlim_max = (rlim_t)(total + 10);
269#ifdef HAVE_SETRLIMIT
270 if(setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
271 log_warn("setrlimit: %s", strerror(errno));
272#endif
273 log_warn("cannot increase max open fds from %u to %u",
274 (unsigned)avail, (unsigned)total+10);
275 /* check that calculation below does not underflow,
276 * with 15 as margin */
277 if(numthread*perthread_noudp+15 > avail)
278 fatal_exit("too much tcp. not enough fds.");
279 cfg->outgoing_num_ports = (int)((avail
280 - numthread*perthread_noudp
281 - 10 /* safety margin */) /numthread);
282 log_warn("continuing with less udp ports: %u",
283 cfg->outgoing_num_ports);
284 log_warn("increase ulimit or decrease threads, "
285 "ports in config to remove this warning");
286 return;
287#ifdef HAVE_SETRLIMIT
288 }
289#endif
290 verbose(VERB_ALGO, "increased limit(open files) from %u to %u",
291 (unsigned)avail, (unsigned)total+10);
292 }
293#else
294 (void)cfg;
295#endif /* HAVE_GETRLIMIT */
296#endif /* S_SPLINT_S */
297}
298
299/** set verbosity, check rlimits, cache settings */
300static void
301apply_settings(struct daemon* daemon, struct config_file* cfg,
302 int cmdline_verbose, int debug_mode)
303{
304 /* apply if they have changed */
305 verbosity = cmdline_verbose + cfg->verbosity;
306 if (debug_mode > 1) {
307 cfg->use_syslog = 0;
308 cfg->logfile = NULL;
309 }
310 daemon_apply_cfg(daemon, cfg);
311 checkrlimits(cfg);
312}
313
314#ifdef HAVE_KILL
315/** Read existing pid from pidfile.
316 * @param file: file name of pid file.
317 * @return: the pid from the file or -1 if none.

--- 342 unchanged lines hidden (view full) ---

660 if(!(cfg = config_create()))
661 fatal_exit("Could not alloc config defaults");
662 if(!config_read(cfg, cfgfile, daemon->chroot)) {
663 if(errno != ENOENT)
664 fatal_exit("Could not read config file: %s",
665 cfgfile);
666 log_warn("Continuing with default config settings");
667 }
668 apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
669
670 /* prepare */
671 if(!daemon_open_shared_ports(daemon))
672 fatal_exit("could not open ports");
673 if(!done_setup) {
674 perform_setup(daemon, cfg, debug_mode, &cfgfile);
675 done_setup = 1;
676 } else {

--- 63 unchanged lines hidden (view full) ---

740 cmdline_cfg = 1;
741#endif
742 break;
743 case 'v':
744 cmdline_verbose ++;
745 verbosity++;
746 break;
747 case 'd':
748 debug_mode++;
749 break;
750 case 'w':
751 winopt = optarg;
752 break;
753 case '?':
754 case 'h':
755 default:
756 usage();

--- 24 unchanged lines hidden ---