From a89c859f38b4154be1ce183150e8622ae667a212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= <ecklm94@gmail.com>
Date: Fri, 27 May 2016 00:06:30 +0200
Subject: [PATCH] =?UTF-8?q?Kis=20kieg=C3=A9sz=C3=ADt=C5=91=20funkci=C3=B3?=
 =?UTF-8?q?=20(#8)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 main.cpp           | 11 +++++++++--
 src/dns_server.cpp |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/main.cpp b/main.cpp
index da70363..813eb2c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -31,10 +31,12 @@ void print_help();
 int main(int argc, char *argv[])
 {
 	int cli_option;
+	int thread_num = 1;
 	bool run_as_daemon = false;
 	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)
 		{
 			case 'd':
@@ -49,6 +51,11 @@ int main(int argc, char *argv[])
 			case 'v':
 				verbose = true;
 				break;
+			case 't':
+				ti = atoi(optarg);
+				if(ti>0)
+					thread_num = ti;
+				break;
 			case 'h':
 				print_help();
 				exit(EXIT_SUCCESS);
@@ -145,7 +152,6 @@ int main(int argc, char *argv[])
 // ----------------- INIT END --------------------------
 
 // ------------------ SERVE ----------------------------
-	int thread_num = 8;
 	server.serve_in_threads(thread_num);
 	bool stop = false;
 	while(!stop)
@@ -173,6 +179,7 @@ For more info look at the man page.
 
 Options:
 	-d Run as daemon
+	-t Number of threads to start. Only makes sense with -d.
 	-s Statistics from daemon
 	-k Kill daemon
 	-v Verbose
diff --git a/src/dns_server.cpp b/src/dns_server.cpp
index 04c4d88..d06c37c 100644
--- a/src/dns_server.cpp
+++ b/src/dns_server.cpp
@@ -168,4 +168,5 @@ void dns_server::serve_in_threads(int n) {
 		stop();
 		throw;
 	}
+	log_on_demand(LOG_INFO, "%d thread(s) started.", n);
 }
-- 
GitLab