diff --git a/config.h b/config.h index 52ed09a..94e7576 100644 --- a/config.h +++ b/config.h @@ -9,6 +9,7 @@ typedef struct { char* htdocs; char* tmpdir; dictionary rules; + int backlog; }config_t; extern config_t server_config; \ No newline at end of file diff --git a/http_server.c b/http_server.c index cc25984..b88bf84 100644 --- a/http_server.c +++ b/http_server.c @@ -339,7 +339,8 @@ int startup(unsigned *port) error_die("getsockname"); *port = ntohs(name.sin_port); } - if (listen(httpd, 5) < 0) + printf("back log is %d\n", server_config.backlog); + if (listen(httpd, server_config.backlog) < 0) error_die("listen"); return(httpd); } diff --git a/httpd.c b/httpd.c index eccc24b..ee4d25f 100644 --- a/httpd.c +++ b/httpd.c @@ -22,6 +22,9 @@ static int config_handler(void* conf, const char* section, const char* name, pconfig->htdocs = strdup(value); } else if(MATCH("SERVER", "tmpdir")) { pconfig->tmpdir = strdup(value); + } + else if(MATCH("SERVER", "backlog")) { + pconfig->backlog = atoi(value); } else if (strcmp(section, "RULES") == 0) { @@ -61,6 +64,7 @@ void load_config(const char* file) server_config.db_path = "databases/"; server_config.htdocs = "htdocs"; server_config.tmpdir = "tmp"; + server_config.backlog = 100; server_config.rules = dict(); if (ini_parse(file, config_handler, &server_config) < 0) { LOG("Can't load '%s'\n. Used defaut configuration", file);