mirror of
https://github.com/lxsang/ant-http
synced 2024-11-17 17:08:20 +01:00
scheduler timeout should be configurable
This commit is contained in:
parent
e9cd1addf7
commit
0daef95c25
@ -165,6 +165,10 @@ static int config_handler(void *conf, const char *section, const char *name,
|
||||
{
|
||||
pconfig->debug_enable = atoi(value);
|
||||
}
|
||||
else if (MATCH("SERVER", "scheduler_timeout"))
|
||||
{
|
||||
pconfig->scheduler_timeout = atoi(value);
|
||||
}
|
||||
#ifdef USE_ZLIB
|
||||
else if (MATCH("SERVER", "gzip_enable"))
|
||||
{
|
||||
@ -274,6 +278,7 @@ void load_config(const char *file)
|
||||
server_config.gzip_enable = 0;
|
||||
server_config.gzip_types = NULL;
|
||||
server_config.debug_enable = 0;
|
||||
server_config.scheduler_timeout = 30; // 30 s
|
||||
// put it default mimes
|
||||
for (int i = 0; _mimes[i].type != NULL; i++)
|
||||
{
|
||||
|
23
httpd.c
23
httpd.c
@ -21,7 +21,7 @@
|
||||
snprintf(buff, BUFFLEN, ##__VA_ARGS__); \
|
||||
ret = write(fd, buff, strlen(buff));
|
||||
|
||||
static antd_scheduler_t* scheduler;
|
||||
static antd_scheduler_t *scheduler;
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
|
||||
@ -241,7 +241,7 @@ static void antd_monitor(port_config_t *pcnf)
|
||||
antd_scheduler_unlock(scheduler);
|
||||
// create callback for the server
|
||||
task = antd_create_task(accept_request, (void *)request, finish_request, client->last_io);
|
||||
antd_task_bind_event(task,client->sock,0, TASK_EVT_ON_WRITABLE| TASK_EVT_ON_READABLE);
|
||||
antd_task_bind_event(task, client->sock, 0, TASK_EVT_ON_WRITABLE | TASK_EVT_ON_READABLE);
|
||||
antd_scheduler_add_task(scheduler, task);
|
||||
}
|
||||
}
|
||||
@ -299,19 +299,26 @@ void antd_scheduler_destroy_data(void *data)
|
||||
{
|
||||
antd_request_t *rq = (antd_request_t *)data;
|
||||
antd_client_t *proxy = (antd_client_t *)dvalue(rq->request, "PROXY_HANDLE");
|
||||
if(proxy)
|
||||
if (proxy)
|
||||
{
|
||||
close(proxy->sock);
|
||||
}
|
||||
finish_request(data);
|
||||
}
|
||||
|
||||
int antd_scheduler_validate_data(antd_task_t *task)
|
||||
{
|
||||
config_t *conf = config();
|
||||
LOG("Use server configured scheduler timeout %d", conf->scheduler_timeout);
|
||||
return !(difftime(time(NULL), task->access_time) > conf->scheduler_timeout);
|
||||
}
|
||||
|
||||
int antd_task_data_id(void *data)
|
||||
{
|
||||
antd_request_t *rq = (antd_request_t *)data;
|
||||
if(!rq)
|
||||
return 0;
|
||||
return antd_scheduler_next_id(scheduler,rq->client->sock);
|
||||
if (!rq)
|
||||
return 0;
|
||||
return antd_scheduler_next_id(scheduler, rq->client->sock);
|
||||
/*UNUSED(data);
|
||||
return antd_scheduler_next_id(scheduler,0);*/
|
||||
}
|
||||
@ -339,7 +346,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
config_t *conf = config();
|
||||
// start syslog
|
||||
if(conf->debug_enable == 1)
|
||||
if (conf->debug_enable == 1)
|
||||
{
|
||||
setlogmask(LOG_UPTO(LOG_NOTICE));
|
||||
}
|
||||
@ -361,7 +368,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
// enable scheduler
|
||||
// default to 4 workers
|
||||
scheduler = antd_scheduler_init( conf->n_workers, conf->stat_fifo_path);
|
||||
scheduler = antd_scheduler_init(conf->n_workers, conf->stat_fifo_path);
|
||||
if (scheduler == NULL)
|
||||
{
|
||||
ERROR("Unable to initialise scheduler. Exit");
|
||||
|
@ -86,6 +86,7 @@ typedef struct
|
||||
int maxcon;
|
||||
int connection;
|
||||
int n_workers;
|
||||
int scheduler_timeout;
|
||||
int max_upload_size;
|
||||
// ssl
|
||||
int enable_ssl;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "utils.h"
|
||||
#include "bst.h"
|
||||
|
||||
#define MAX_VALIDITY_INTERVAL 30 // s
|
||||
#define MAX_VALIDITY_INTERVAL 30
|
||||
#define MAX_FIFO_NAME_SZ 255
|
||||
|
||||
// callback definition
|
||||
|
Loading…
Reference in New Issue
Block a user