configurable timeout for first request
Costa Tsaousis (ktsaou) committed
Jan 16, 2018 at 00:09 UTC
40f200e273462d7fe2d36bb4542adf8b1923f3d7
4 files changed
+6
-2
src/main.c
+2
-1
@@ -99,7 +99,8 @@ void web_server_threading_selection(void) {
99
}
100
101
void web_server_config_options(void) {
102
- web_client_timeout = (int) config_get_number(CONFIG_SECTION_WEB, "disconnect idle clients after seconds", DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS);
102
+ web_client_timeout = (int) config_get_number(CONFIG_SECTION_WEB, "disconnect idle clients after seconds", web_client_timeout);
103
+ web_client_first_request_timeout = (int) config_get_number(CONFIG_SECTION_WEB, "timeout for first request", web_client_first_request_timeout);
104
105
respect_web_browser_do_not_track_policy = config_get_boolean(CONFIG_SECTION_WEB, "respect do not track policy", respect_web_browser_do_not_track_policy);
106
web_x_frame_options = config_get(CONFIG_SECTION_WEB, "x-frame-options response header", "");
src/socket.c
+1
-1
@@ -1351,7 +1351,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1351
.inf = NULL,
1352
.first_free = NULL,
1353
1354
- .complete_request_timeout = 30,
1354
+ .complete_request_timeout = web_client_first_request_timeout,
1355
.idle_timeout = web_client_timeout,
1356
.checks_every = (web_client_timeout / 3) + 1,
1357
src/web_server.c
+1
@@ -400,6 +400,7 @@ static struct web_client *web_client_create_on_listenfd(int listener) {
400
// 4. it copies data from input to output if mode is FILECOPY
401
402
int web_client_timeout = DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS;
403
+int web_client_first_request_timeout = DEFAULT_TIMEOUT_TO_RECEIVE_FIRST_WEB_REQUEST;
404
405
static void multi_threaded_web_client_worker_main_cleanup(void *ptr) {
406
struct web_client *w = ptr;
src/web_server.h
+2
@@ -38,7 +38,9 @@ extern void *socket_listen_main_single_threaded(void *ptr);
38
extern void *socket_listen_main_static_threaded(void *ptr);
39
extern int api_listen_sockets_setup(void);
40
41
+#define DEFAULT_TIMEOUT_TO_RECEIVE_FIRST_WEB_REQUEST 60
42
#define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
43
extern int web_client_timeout;
44
+extern int web_client_first_request_timeout;
45
46
#endif /* NETDATA_WEB_SERVER_H */