mirror of
https://github.com/lxsang/ant-http
synced 2025-07-15 05:19:55 +02:00
fix open ssl bug
This commit is contained in:
@ -100,8 +100,28 @@ int antd_recv(void *src, void* data, int len)
|
||||
#ifdef USE_OPENSSL
|
||||
if(usessl())
|
||||
{
|
||||
//LOG("SSL READ\n");
|
||||
// TODO: blocking is not good, need a workaround
|
||||
set_nonblock(source->sock);
|
||||
ret = SSL_read((SSL*) source->ssl, data, len);
|
||||
set_nonblock(source->sock);
|
||||
/*
|
||||
int stat, r, st;
|
||||
do{
|
||||
ret = SSL_read((SSL*) source->ssl, data, len);
|
||||
stat = SSL_get_error((SSL*)source->ssl, r);
|
||||
} while(ret == -1 &&
|
||||
(
|
||||
stat == SSL_ERROR_WANT_READ ||
|
||||
stat == SSL_ERROR_WANT_WRITE ||
|
||||
stat == SSL_ERROR_NONE ||
|
||||
(stat == SSL_ERROR_SYSCALL && r== 0 && !ERR_get_error())
|
||||
));
|
||||
if(ret == -1)
|
||||
{
|
||||
LOG("Problem reading %d %d %d\n", ret, stat, r);
|
||||
}
|
||||
//set_nonblock(source->sock);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,6 +136,19 @@ int antd_recv(void *src, void* data, int len)
|
||||
}*/
|
||||
return ret;
|
||||
}
|
||||
void set_nonblock(int socket) {
|
||||
int flags;
|
||||
flags = fcntl(socket,F_GETFL,0);
|
||||
//assert(flags != -1);
|
||||
fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
void set_block()
|
||||
{
|
||||
int flags;
|
||||
flags = fcntl(socket,F_GETFL,0);
|
||||
//assert(flags != -1);
|
||||
fcntl(socket, F_SETFL, flags & (~O_NONBLOCK));
|
||||
}
|
||||
int antd_close(void* src)
|
||||
{
|
||||
if(!src) return -1;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifdef USE_DB
|
||||
#include "dbhelper.h"
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include "dictionary.h"
|
||||
#include "list.h"
|
||||
#include "ini.h"
|
||||
@ -33,6 +34,9 @@ typedef struct{
|
||||
int sock;
|
||||
void* ssl;
|
||||
char* ip;
|
||||
#ifdef USE_OPENSSL
|
||||
int status;
|
||||
#endif
|
||||
} antd_client_t;
|
||||
|
||||
typedef struct {
|
||||
@ -60,7 +64,8 @@ typedef struct {
|
||||
char* sslkey;
|
||||
#endif
|
||||
}config_t;
|
||||
|
||||
void set_nonblock(int socket);
|
||||
void set_block(int socket);
|
||||
int response(void*, const char*);
|
||||
void ctype(void*,const char*);
|
||||
void redirect(void*,const char*);
|
||||
|
@ -195,6 +195,7 @@ void antd_add_task(antd_scheduler_t* scheduler, antd_task_t* task)
|
||||
{
|
||||
// check if task is exist
|
||||
int prio = task->priority>N_PRIORITY-1?N_PRIORITY-1:task->priority;
|
||||
//LOG("Prio is %d\n", prio);
|
||||
pthread_mutex_lock(&scheduler->scheduler_lock);
|
||||
enqueue(&scheduler->task_queue[prio], task);
|
||||
pthread_mutex_unlock(&scheduler->scheduler_lock);
|
||||
|
Reference in New Issue
Block a user