fix deadlock

This commit is contained in:
lxsang 2018-10-14 11:19:06 +02:00
parent 54bb040ef4
commit ee5c630052
3 changed files with 5 additions and 4 deletions

View File

@ -190,6 +190,7 @@ void *accept_request(void *data)
if (server_config.usessl == 1 && client->status == 0) if (server_config.usessl == 1 && client->status == 0)
{ {
if(client->attempt > MAX_ATTEMPT) return task; if(client->attempt > MAX_ATTEMPT) return task;
LOG("Atttempt %d\n", client->attempt);
if (SSL_accept((SSL *)client->ssl) == -1) if (SSL_accept((SSL *)client->ssl) == -1)
{ {
client->attempt++; client->attempt++;

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 500 #define MAX_ATTEMPT 5000
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
int __attribute__((weak)) usessl(); int __attribute__((weak)) usessl();
#endif #endif

View File

@ -153,13 +153,13 @@ void antd_scheduler_init(antd_scheduler_t* scheduler, int n)
scheduler->workers_queue = NULL; scheduler->workers_queue = NULL;
scheduler->pending_task = 0 ; scheduler->pending_task = 0 ;
// init semaphore // init semaphore
scheduler->scheduler_sem = sem_open("scheduler", O_RDWR | O_CREAT, S_IRWXU); scheduler->scheduler_sem = sem_open("scheduler", O_CREAT, 0600, 0);
if (!scheduler->scheduler_sem) if (scheduler->scheduler_sem == SEM_FAILED)
{ {
LOG("Cannot open semaphore for scheduler\n"); LOG("Cannot open semaphore for scheduler\n");
exit(-1); exit(-1);
} }
scheduler->worker_sem = sem_open("worker", O_RDWR | O_CREAT, S_IRWXU); scheduler->worker_sem = sem_open("worker", O_CREAT, 0600, 0);
if (!scheduler->worker_sem) if (!scheduler->worker_sem)
{ {
LOG("Cannot open semaphore for workers\n"); LOG("Cannot open semaphore for workers\n");