Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-sdk
  • MIKA83/cellframe-sdk
2 results
Show changes
Commits on Source (5)
......@@ -2,7 +2,7 @@ project(cellframe-sdk C)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_STANDARD 11)
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-112")
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-113")
add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"")
set(DAPSDK_MODULES "")
......
......@@ -27,7 +27,7 @@
///========================================================================
/* Names for the four varieties of Dilithium */
typedef enum { MODE_0, MODE_1, MODE_2, MODE_3 } __attribute__((aligned(8))) dilithium_kind_t;
typedef enum { MODE_0, MODE_1, MODE_2, MODE_3 } __attribute__((aligned(4))) dilithium_kind_t;
typedef struct {
dilithium_kind_t kind; /* the kind of Dilithium (i.e. *this* choice of parameters) */
......
......@@ -126,25 +126,28 @@ static bool s_timer_timeout_check(void * a_arg)
if(dap_events_socket_check_unsafe(l_worker, l_es) ){
if (!dap_uint128_check_equal(l_es->uuid,l_es_handler->uuid)){
// Timer esocket wrong argument, ignore this timeout...
DAP_DELETE(l_es_handler);
log_it(L_DEBUG,"Timer esocket wrong argument, ignore this timeout...");
DAP_DEL_Z(l_es_handler)
return false;
}
dap_client_http_pvt_t * l_http_pvt = PVT(l_es);
log_it(L_WARNING,"Connection timeout for request http://%s:%u/%s, possible network problems or host is down",
l_http_pvt->uplink_addr, l_http_pvt->uplink_port, l_http_pvt->path);
if(l_http_pvt->error_callback) {
l_http_pvt->error_callback(ETIMEDOUT, l_http_pvt->obj);
l_http_pvt->were_callbacks_called = true;
}
l_http_pvt->is_closed_by_timeout = true;
log_it(L_INFO, "Close %s sock %u type %d by timeout",
l_es->remote_addr_str ? l_es->remote_addr_str : "", l_es->socket, l_es->type);
dap_events_socket_remove_and_delete_unsafe(l_es, true);
} else {
log_it(L_INFO, "Socket %d type %d already disposed", l_es->socket, l_es->type);
}
DAP_DELETE(l_es_handler);
if (l_es->flags & DAP_SOCK_CONNECTING ){
dap_client_http_pvt_t * l_http_pvt = PVT(l_es);
log_it(L_WARNING,"Connecting timeout for request http://%s:%u/%s, possible network problems or host is down",
l_http_pvt->uplink_addr, l_http_pvt->uplink_port, l_http_pvt->path);
if(l_http_pvt->error_callback) {
l_http_pvt->error_callback(ETIMEDOUT, l_http_pvt->obj);
l_http_pvt->were_callbacks_called = true;
}
l_http_pvt->is_closed_by_timeout = true;
log_it(L_INFO, "Close %s sock %u type %d by timeout",
l_es->remote_addr_str ? l_es->remote_addr_str : "", l_es->socket, l_es->type);
dap_events_socket_remove_and_delete_unsafe(l_es, true);
}else
log_it(L_DEBUG,"Socket %d is connected, close check timer", l_es->socket);
}else
log_it(L_DEBUG,"Esocket %p is finished, close check timer", l_es);
DAP_DEL_Z(l_es_handler)
return false;
}
......@@ -501,7 +504,10 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin
log_it(L_DEBUG, "Connecting to %s:%u", a_uplink_addr, a_uplink_port);
l_http_pvt->worker = a_worker?a_worker: dap_events_worker_get_auto();
dap_worker_add_events_socket(l_ev_socket,l_http_pvt->worker);
dap_timerfd_start_on_worker(l_http_pvt->worker,s_client_timeout_ms, s_timer_timeout_check,l_ev_socket);
dap_events_socket_handler_t * l_ev_socket_handler = DAP_NEW_Z(dap_events_socket_handler_t);
l_ev_socket_handler->esocket = l_ev_socket;
l_ev_socket_handler->uuid = l_ev_socket->uuid;
dap_timerfd_start_on_worker(l_http_pvt->worker,s_client_timeout_ms, s_timer_timeout_check,l_ev_socket_handler);
return l_http_pvt;
} else {
log_it(L_ERROR, "Socket %d connecting error: %d", l_ev_socket->socket, l_err2);
......
......@@ -184,6 +184,46 @@ static void s_stream_connected(dap_client_pvt_t * a_client_pvt)
s_stage_status_after(a_client_pvt);
}
static bool s_timer_timeout_check(void * a_arg)
{
dap_events_socket_handler_t *l_es_handler = (dap_events_socket_handler_t*) a_arg;
assert(l_es_handler);
dap_events_socket_t * l_es = l_es_handler->esocket;
assert(l_es);
dap_events_t * l_events = dap_events_get_default();
assert(l_events);
dap_worker_t * l_worker =(dap_worker_t*) pthread_getspecific(l_events->pth_key_worker); // We're in own esocket context
assert(l_worker);
if(dap_events_socket_check_unsafe(l_worker, l_es) ){
if (!dap_uint128_check_equal(l_es->uuid,l_es_handler->uuid)){
log_it(L_DEBUG,"Timer esocket wrong argument, ignore this timeout...");
DAP_DEL_Z(l_es_handler)
return false;
}
if (l_es->flags & DAP_SOCK_CONNECTING ){
dap_client_pvt_t * l_client_pvt =(dap_client_pvt_t *) l_es->_inheritor;//(l_client) ? DAP_CLIENT_PVT(l_client) : NULL;
log_it(L_WARNING,"Connecting timeout for stream uplink request http://%s:%u/, possible network problems or host is down",
l_client_pvt->uplink_addr, l_client_pvt->uplink_port);
l_client_pvt->is_closed_by_timeout = true;
if(l_es->callbacks.error_callback) {
l_es->callbacks.error_callback(l_es,ETIMEDOUT);
}
log_it(L_INFO, "Close %s sock %u type %d by timeout",
l_es->remote_addr_str ? l_es->remote_addr_str : "", l_es->socket, l_es->type);
dap_events_socket_remove_and_delete_unsafe(l_es, true);
}else
log_it(L_DEBUG,"Socket %d is connected, close check timer", l_es->socket);
}else
log_it(L_DEBUG,"Esocket %p is finished, close check timer", l_es);
DAP_DEL_Z(l_es_handler)
return false;
}
/**
* @brief s_client_internal_stage_status_proc
* @param a_client
......@@ -411,6 +451,10 @@ static bool s_stage_status_after(dap_client_pvt_t * a_client_pvt)
log_it(L_INFO,"Connecting stream to remote %s:%u",a_client_pvt->uplink_addr, a_client_pvt->uplink_port);
// add to dap_worker
dap_worker_add_events_socket( a_client_pvt->stream_es, l_worker);
dap_events_socket_handler_t * l_stream_es_handler = DAP_NEW_Z(dap_events_socket_handler_t);
l_stream_es_handler->esocket = a_client_pvt->stream_es;
l_stream_es_handler->uuid = a_client_pvt->stream_es->uuid;
dap_timerfd_start_on_worker(a_client_pvt->worker, 10000, s_timer_timeout_check,l_stream_es_handler);
}
}
}
......
......@@ -88,6 +88,7 @@ typedef struct dap_client_internal
bool is_encrypted;
bool is_encrypted_headers;
bool is_close_session;// the last request in session, in the header will be added "SessionCloseAfterRequest: true"
bool is_closed_by_timeout;
dap_client_callback_data_size_t request_response_callback;
dap_client_callback_int_t request_error_callback;
......
......@@ -149,7 +149,7 @@ dap_events_socket_t *dap_events_socket_wrap_no_add( dap_events_t *a_events,
l_ret->buf_out = a_callbacks->timer_callback ? NULL : DAP_NEW_Z_SIZE(byte_t, l_ret->buf_out_size_max + 1);
l_ret->buf_in_size = l_ret->buf_out_size = 0;
#if defined(DAP_EVENTS_CAPS_EPOLL)
ret->ev_base_flags = EPOLLERR | EPOLLRDHUP | EPOLLHUP;
l_ret->ev_base_flags = EPOLLERR | EPOLLRDHUP | EPOLLHUP;
#elif defined(DAP_EVENTS_CAPS_POLL)
l_ret->poll_base_flags = POLLERR | POLLRDHUP | POLLHUP;
#endif
......