Skip to content
Snippets Groups Projects
Commit a89c859f authored by dnsadmin's avatar dnsadmin
Browse files

Kis kiegészítő funkció (#8)

parent 12089093
Branches
No related tags found
No related merge requests found
...@@ -31,10 +31,12 @@ void print_help(); ...@@ -31,10 +31,12 @@ void print_help();
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int cli_option; int cli_option;
int thread_num = 1;
bool run_as_daemon = false; bool run_as_daemon = false;
std::vector<command> command_list; std::vector<command> command_list;
while((cli_option = getopt (argc, argv, "dmskvh")) != -1) while((cli_option = getopt (argc, argv, "dmskvht:")) != -1)
{ {
int ti = 0;
switch(cli_option) switch(cli_option)
{ {
case 'd': case 'd':
...@@ -49,6 +51,11 @@ int main(int argc, char *argv[]) ...@@ -49,6 +51,11 @@ int main(int argc, char *argv[])
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
case 't':
ti = atoi(optarg);
if(ti>0)
thread_num = ti;
break;
case 'h': case 'h':
print_help(); print_help();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
...@@ -145,7 +152,6 @@ int main(int argc, char *argv[]) ...@@ -145,7 +152,6 @@ int main(int argc, char *argv[])
// ----------------- INIT END -------------------------- // ----------------- INIT END --------------------------
// ------------------ SERVE ---------------------------- // ------------------ SERVE ----------------------------
int thread_num = 8;
server.serve_in_threads(thread_num); server.serve_in_threads(thread_num);
bool stop = false; bool stop = false;
while(!stop) while(!stop)
...@@ -173,6 +179,7 @@ For more info look at the man page. ...@@ -173,6 +179,7 @@ For more info look at the man page.
Options: Options:
-d Run as daemon -d Run as daemon
-t Number of threads to start. Only makes sense with -d.
-s Statistics from daemon -s Statistics from daemon
-k Kill daemon -k Kill daemon
-v Verbose -v Verbose
......
...@@ -168,4 +168,5 @@ void dns_server::serve_in_threads(int n) { ...@@ -168,4 +168,5 @@ void dns_server::serve_in_threads(int n) {
stop(); stop();
throw; throw;
} }
log_on_demand(LOG_INFO, "%d thread(s) started.", n);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment