use heavy task by default

This commit is contained in:
lxsang 2018-10-14 21:41:59 +02:00
parent 487e5b108b
commit 81ff9f2c3c
2 changed files with 9 additions and 4 deletions

View File

@ -181,6 +181,13 @@ void *accept_request(void *data)
if (sel == 0 || (!FD_ISSET(client->sock, &read_flags) && !FD_ISSET(client->sock, &write_flags))) if (sel == 0 || (!FD_ISSET(client->sock, &read_flags) && !FD_ISSET(client->sock, &write_flags)))
{ {
// retry it later // 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; task->handle = accept_request;
return task; return task;
} }
@ -189,11 +196,9 @@ void *accept_request(void *data)
int ret = -1, stat; int ret = -1, stat;
if (server_config.usessl == 1 && client->status == 0) if (server_config.usessl == 1 && client->status == 0)
{ {
//if(client->attempt > MAX_ATTEMPT) return task;
//LOG("Atttempt %d\n", client->attempt); //LOG("Atttempt %d\n", client->attempt);
if (SSL_accept((SSL *)client->ssl) == -1) if (SSL_accept((SSL *)client->ssl) == -1)
{ {
client->attempt++;
stat = SSL_get_error((SSL *)client->ssl, ret); stat = SSL_get_error((SSL *)client->ssl, ret);
switch (stat) switch (stat)
{ {

View File

@ -26,7 +26,7 @@
#define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}" #define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}"
#define FORM_URL_ENCODE "application/x-www-form-urlencoded" #define FORM_URL_ENCODE "application/x-www-form-urlencoded"
#define FORM_MULTI_PART "multipart/form-data" #define FORM_MULTI_PART "multipart/form-data"
#define MAX_ATTEMPT 5000 #define MAX_ATTEMPT 1000
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
int __attribute__((weak)) usessl(); int __attribute__((weak)) usessl();
#endif #endif
@ -37,8 +37,8 @@ typedef struct{
char* ip; char* ip;
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
int status; int status;
int attempt;
#endif #endif
int attempt;
} antd_client_t; } antd_client_t;
typedef struct { typedef struct {