daemon.c (5a2b666ce590a56f147e167aa07684af2d6b854a) | daemon.c (b75612f8e7445139aa2b10038feab06da4b45cc1) |
---|---|
1/* 2 * daemon/daemon.c - collection of workers that handles requests. 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 --- 385 unchanged lines hidden (view full) --- 394 hash_set_raninit((uint32_t)ub_random(daemon->rand)); 395 shufport = (int*)calloc(65536, sizeof(int)); 396 if(!shufport) 397 fatal_exit("out of memory during daemon init"); 398 numport = daemon_get_shufport(daemon, shufport); 399 verbose(VERB_ALGO, "total of %d outgoing ports available", numport); 400 401 daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1); | 1/* 2 * daemon/daemon.c - collection of workers that handles requests. 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 --- 385 unchanged lines hidden (view full) --- 394 hash_set_raninit((uint32_t)ub_random(daemon->rand)); 395 shufport = (int*)calloc(65536, sizeof(int)); 396 if(!shufport) 397 fatal_exit("out of memory during daemon init"); 398 numport = daemon_get_shufport(daemon, shufport); 399 verbose(VERB_ALGO, "total of %d outgoing ports available", numport); 400 401 daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1); |
402 if(daemon->reuseport && (int)daemon->num < (int)daemon->num_ports) { 403 log_warn("cannot reduce num-threads to %d because so-reuseport " 404 "so continuing with %d threads.", (int)daemon->num, 405 (int)daemon->num_ports); 406 daemon->num = (int)daemon->num_ports; 407 } |
|
402 daemon->workers = (struct worker**)calloc((size_t)daemon->num, 403 sizeof(struct worker*)); 404 if(daemon->cfg->dnstap) { 405#ifdef USE_DNSTAP 406 daemon->dtenv = dt_create(daemon->cfg->dnstap_socket_path, 407 (unsigned int)daemon->num); 408 if (!daemon->dtenv) 409 fatal_exit("dt_create failed"); --- 49 unchanged lines hidden (view full) --- 459 ub_thread_blocksigs(); 460#ifdef THREADS_DISABLED 461 /* close pipe ends used by main */ 462 tube_close_write(worker->cmd); 463 close_other_pipes(worker->daemon, worker->thread_num); 464#endif 465#ifdef SO_REUSEPORT 466 if(worker->daemon->cfg->so_reuseport) | 408 daemon->workers = (struct worker**)calloc((size_t)daemon->num, 409 sizeof(struct worker*)); 410 if(daemon->cfg->dnstap) { 411#ifdef USE_DNSTAP 412 daemon->dtenv = dt_create(daemon->cfg->dnstap_socket_path, 413 (unsigned int)daemon->num); 414 if (!daemon->dtenv) 415 fatal_exit("dt_create failed"); --- 49 unchanged lines hidden (view full) --- 465 ub_thread_blocksigs(); 466#ifdef THREADS_DISABLED 467 /* close pipe ends used by main */ 468 tube_close_write(worker->cmd); 469 close_other_pipes(worker->daemon, worker->thread_num); 470#endif 471#ifdef SO_REUSEPORT 472 if(worker->daemon->cfg->so_reuseport) |
467 port_num = worker->thread_num; | 473 port_num = worker->thread_num % worker->daemon->num_ports; |
468 else 469 port_num = 0; 470#endif 471 if(!worker_init(worker, worker->daemon->cfg, 472 worker->daemon->ports[port_num], 0)) 473 fatal_exit("Could not initialize thread"); 474 475 worker_work(worker); --- 218 unchanged lines hidden --- | 474 else 475 port_num = 0; 476#endif 477 if(!worker_init(worker, worker->daemon->cfg, 478 worker->daemon->ports[port_num], 0)) 479 fatal_exit("Could not initialize thread"); 480 481 worker_work(worker); --- 218 unchanged lines hidden --- |