1
0
mirror of https://github.com/lxsang/ant-http synced 2024-07-03 13:39:46 +02:00

add reconfigurable connection baglog

This commit is contained in:
Xuan Sang LE 2018-02-05 23:04:02 +01:00
parent fb43aac923
commit 101cbead6c
3 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ typedef struct {
char* htdocs; char* htdocs;
char* tmpdir; char* tmpdir;
dictionary rules; dictionary rules;
int backlog;
}config_t; }config_t;
extern config_t server_config; extern config_t server_config;

View File

@ -339,7 +339,8 @@ int startup(unsigned *port)
error_die("getsockname"); error_die("getsockname");
*port = ntohs(name.sin_port); *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"); error_die("listen");
return(httpd); return(httpd);
} }

View File

@ -22,6 +22,9 @@ static int config_handler(void* conf, const char* section, const char* name,
pconfig->htdocs = strdup(value); pconfig->htdocs = strdup(value);
} else if(MATCH("SERVER", "tmpdir")) { } else if(MATCH("SERVER", "tmpdir")) {
pconfig->tmpdir = strdup(value); pconfig->tmpdir = strdup(value);
}
else if(MATCH("SERVER", "backlog")) {
pconfig->backlog = atoi(value);
} }
else if (strcmp(section, "RULES") == 0) else if (strcmp(section, "RULES") == 0)
{ {
@ -61,6 +64,7 @@ void load_config(const char* file)
server_config.db_path = "databases/"; server_config.db_path = "databases/";
server_config.htdocs = "htdocs"; server_config.htdocs = "htdocs";
server_config.tmpdir = "tmp"; server_config.tmpdir = "tmp";
server_config.backlog = 100;
server_config.rules = dict(); server_config.rules = dict();
if (ini_parse(file, config_handler, &server_config) < 0) { if (ini_parse(file, config_handler, &server_config) < 0) {
LOG("Can't load '%s'\n. Used defaut configuration", file); LOG("Can't load '%s'\n. Used defaut configuration", file);