mirror of
https://github.com/lxsang/ant-http
synced 2025-04-19 17:06:44 +02: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* 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;
|
@ -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);
|
||||||
}
|
}
|
||||||
|
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);
|
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user