1
0
mirror of https://github.com/lxsang/ant-http synced 2024-07-01 12:59:47 +02:00

scheduler timeout should be configurable

This commit is contained in:
lxsang 2021-10-08 22:47:27 +02:00
parent e9cd1addf7
commit 0daef95c25
4 changed files with 22 additions and 9 deletions

View File

@ -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++)
{

View File

@ -306,6 +306,13 @@ void antd_scheduler_destroy_data(void *data)
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;

View File

@ -86,6 +86,7 @@ typedef struct
int maxcon;
int connection;
int n_workers;
int scheduler_timeout;
int max_upload_size;
// ssl
int enable_ssl;

View File

@ -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