mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 00:38:21 +01:00
add reconfigurable connection baglog
This commit is contained in:
parent
fb43aac923
commit
101cbead6c
1
config.h
1
config.h
@ -9,6 +9,7 @@ typedef struct {
|
||||
char* htdocs;
|
||||
char* tmpdir;
|
||||
dictionary rules;
|
||||
int backlog;
|
||||
}config_t;
|
||||
|
||||
extern config_t server_config;
|
@ -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);
|
||||
}
|
||||
|
4
httpd.c
4
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);
|
||||
|
Loading…
Reference in New Issue
Block a user