From 81ff9f2c3cce77fdf9d3e3bb90875e5bde13295e Mon Sep 17 00:00:00 2001 From: lxsang Date: Sun, 14 Oct 2018 21:41:59 +0200 Subject: [PATCH] use heavy task by default --- http_server.c | 9 +++++++-- libs/handle.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/http_server.c b/http_server.c index e9d4d4e..655eb07 100644 --- a/http_server.c +++ b/http_server.c @@ -181,6 +181,13 @@ void *accept_request(void *data) if (sel == 0 || (!FD_ISSET(client->sock, &read_flags) && !FD_ISSET(client->sock, &write_flags))) { // retry it later + if(client->attempt > MAX_ATTEMPT) + { + LOG("Too much attempt, give up on %d\n", client->sock); + server_config.connection++; + return task; + } + client->attempt++; task->handle = accept_request; return task; } @@ -189,11 +196,9 @@ void *accept_request(void *data) int ret = -1, stat; if (server_config.usessl == 1 && client->status == 0) { - //if(client->attempt > MAX_ATTEMPT) return task; //LOG("Atttempt %d\n", client->attempt); if (SSL_accept((SSL *)client->ssl) == -1) { - client->attempt++; stat = SSL_get_error((SSL *)client->ssl, ret); switch (stat) { diff --git a/libs/handle.h b/libs/handle.h index 172975c..5983cab 100644 --- a/libs/handle.h +++ b/libs/handle.h @@ -26,7 +26,7 @@ #define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}" #define FORM_URL_ENCODE "application/x-www-form-urlencoded" #define FORM_MULTI_PART "multipart/form-data" -#define MAX_ATTEMPT 5000 +#define MAX_ATTEMPT 1000 #ifdef USE_OPENSSL int __attribute__((weak)) usessl(); #endif @@ -37,8 +37,8 @@ typedef struct{ char* ip; #ifdef USE_OPENSSL int status; - int attempt; #endif + int attempt; } antd_client_t; typedef struct {