diff --git a/dap-sdk/net/client/dap_client.c b/dap-sdk/net/client/dap_client.c index e1cf46882838cd95dad5d244df523441ef67d45e..54cc9878942eed9eab23b3e49b0c86387e8a7572 100644 --- a/dap-sdk/net/client/dap_client.c +++ b/dap-sdk/net/client/dap_client.c @@ -387,8 +387,10 @@ void dap_client_request_unsafe(dap_client_t * a_client, const char * a_full_path const char * dap_client_error_str(dap_client_error_t a_client_error) { switch(a_client_error){ + case ERROR_OUT_OF_MEMORY: return "OUT_OF_MEMORY"; case ERROR_ENC_NO_KEY: return "ENC_NO_KEY"; case ERROR_ENC_WRONG_KEY: return "ENC_WRONG_KEY"; + case ERROR_ENC_SESSION_CLOSED: return "ENC_SESSION_CLOSED"; case ERROR_STREAM_RESPONSE_WRONG: return "STREAM_RESPONSE_WRONG"; case ERROR_STREAM_RESPONSE_TIMEOUT: return "STREAM_RESPONSE_TIMEOUT"; case ERROR_STREAM_FREEZED: return "STREAM_FREEZED"; diff --git a/dap-sdk/net/client/dap_client_pvt.c b/dap-sdk/net/client/dap_client_pvt.c index 5e89ef28cf244a6075d8e5262617bc01f5abecf9..5cde3f514e631222d20b3feb970827a978133d13 100644 --- a/dap-sdk/net/client/dap_client_pvt.c +++ b/dap-sdk/net/client/dap_client_pvt.c @@ -267,6 +267,7 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) if (!a_client_pvt->session_key_open) { log_it(L_ERROR, "Insufficient memory! May be a huge memory leak present"); a_client_pvt->stage_status = STAGE_STATUS_ERROR; + a_client_pvt->last_error = ERROR_OUT_OF_MEMORY; break; } size_t l_key_size = a_client_pvt->session_key_open->pub_key_data_size; @@ -490,7 +491,7 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) if (a_client_pvt->last_error == ERROR_NETWORK_CONNECTION_TIMEOUT) { l_is_last_attempt = true; } - log_it(L_ERROR, "Error state, doing callback if present"); + log_it(L_ERROR, "Error state( %s), doing callback if present", dap_client_get_error_str(a_client_pvt->client)); if(a_client_pvt->stage_status_error_callback) a_client_pvt->stage_status_error_callback(a_client_pvt->client, (void*) l_is_last_attempt); @@ -800,6 +801,15 @@ static void s_enc_init_response(dap_client_t * a_client, void * a_response, size log_it(L_ERROR, "m_enc_init_response: l_client_pvt is NULL!"); return; } + if (!l_client_pvt->session_key_open){ + log_it(L_ERROR, "m_enc_init_response: session is NULL!"); + l_client_pvt->last_error = ERROR_ENC_SESSION_CLOSED ; + l_client_pvt->stage_status = STAGE_STATUS_ERROR; + s_stage_status_after(l_client_pvt); + return; + + } + if(a_response_size > 10) { // && a_response_size < 50){ char *l_session_id_b64 = NULL; diff --git a/dap-sdk/net/client/include/dap_client.h b/dap-sdk/net/client/include/dap_client.h index 2d481b5ddf5386216a09f76d80729be9f397037e..4bbd72dbb13ba68ff9227249ba4f47afe4cabe2f 100644 --- a/dap-sdk/net/client/include/dap_client.h +++ b/dap-sdk/net/client/include/dap_client.h @@ -55,8 +55,10 @@ typedef enum dap_client_stage_status { typedef enum dap_client_error { ERROR_NO_ERROR = 0, + ERROR_OUT_OF_MEMORY, ERROR_ENC_NO_KEY, ERROR_ENC_WRONG_KEY, + ERROR_ENC_SESSION_CLOSED, ERROR_STREAM_CTL_ERROR, ERROR_STREAM_CTL_ERROR_AUTH, ERROR_STREAM_CTL_ERROR_RESPONSE_FORMAT, diff --git a/dap-sdk/net/core/dap_worker.c b/dap-sdk/net/core/dap_worker.c index aa7cf33af490e43fc645d455fcc7830a9bb5a08a..88d31927a282a9ff77f6ba0c0c8562206d922f79 100644 --- a/dap-sdk/net/core/dap_worker.c +++ b/dap-sdk/net/core/dap_worker.c @@ -317,7 +317,7 @@ void *dap_worker_thread(void *arg) l_cur->buf_out_size = 0; } } - else if (! l_flag_rdhup || !l_flag_error) { + else if ( (! l_flag_rdhup || !l_flag_error ) && (!(l_cur->flags& DAP_SOCK_CONNECTING )) ) { log_it(L_WARNING, "EPOLLIN triggered but nothing to read"); dap_events_socket_set_readable_unsafe(l_cur,false); }