From 2a1c8fc6903298bf21a184e2efd04c6233b6d61f Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net> Date: Tue, 16 Feb 2021 18:08:03 +0700 Subject: [PATCH] [*] Expiration fixes --- .../net/server/http_server/http_client/dap_http_client.c | 8 +++++--- modules/channel/chain/dap_stream_ch_chain.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dap-sdk/net/server/http_server/http_client/dap_http_client.c b/dap-sdk/net/server/http_server/http_client/dap_http_client.c index bb6da1659f..e5396b71c0 100644 --- a/dap-sdk/net/server/http_server/http_client/dap_http_client.c +++ b/dap-sdk/net/server/http_server/http_client/dap_http_client.c @@ -89,7 +89,7 @@ void dap_http_client_new( dap_events_socket_t *a_esocket, void *a_arg ) pthread_rwlock_rdlock(&l_http_client->http->url_proc->cache_rwlock); if(l_http_client->http->url_proc->cache){ - if ( ! l_http_client->http->url_proc->cache->ts_expire || l_http_client->http->url_proc->cache->ts_expire < time(NULL) ){ + if ( ! l_http_client->http->url_proc->cache->ts_expire || l_http_client->http->url_proc->cache->ts_expire >= time(NULL) ){ l_http_client->out_headers = dap_http_headers_dup(l_http_client->http->url_proc->cache->headers); if(s_debug_http) log_it(L_DEBUG,"%d Out: prepare cached headers", l_http_client->esocket->socket); @@ -557,7 +557,7 @@ void dap_http_client_write( dap_events_socket_t * a_esocket, void *a_arg ) if ( ( l_http_client->proc->cache == NULL && l_http_client->proc->data_write_callback ) || ( l_http_client->proc->data_write_callback && - l_http_client->http->url_proc->cache->ts_expire >= time(NULL) && + l_http_client->http->url_proc->cache->ts_expire < time(NULL) && l_http_client->out_cache_position == NULL // Check if we haven't started // to share cached data ) @@ -569,7 +569,9 @@ void dap_http_client_write( dap_events_socket_t * a_esocket, void *a_arg ) l_http_client->http->url_proc->cache = NULL; if(s_debug_http) log_it(L_NOTICE,"Cache expired and dropped out"); - } + }else if (s_debug_http) + log_it(L_DEBUG, "No cache so we call write callback"); + pthread_rwlock_unlock(&l_http_client->proc->cache_rwlock); l_http_client->proc->data_write_callback( l_http_client, NULL ); }else if(l_http_client->proc->cache) { diff --git a/modules/channel/chain/dap_stream_ch_chain.c b/modules/channel/chain/dap_stream_ch_chain.c index 939474bba4..943ed33ab1 100644 --- a/modules/channel/chain/dap_stream_ch_chain.c +++ b/modules/channel/chain/dap_stream_ch_chain.c @@ -187,7 +187,7 @@ static bool s_stream_ch_delete_in_proc(dap_proc_thread_t * a_thread, void * a_ar { (void) a_thread; dap_stream_ch_chain_t * l_ch_chain=(dap_stream_ch_chain_t*) a_arg; - dap_stream_ch_chain_hash_item_t * l_item, *l_tmp; + dap_stream_ch_chain_hash_item_t * l_item = NULL, *l_tmp = NULL; // Clear remote atoms HASH_ITER(hh, l_ch_chain->remote_atoms, l_item, l_tmp){ @@ -307,7 +307,7 @@ static bool s_sync_out_chains_proc_callback(dap_proc_thread_t *a_thread, void *a if (l_iter && l_first_size) { // first packet if (!dap_hash_fast_is_blank(&l_sync_request->request.hash_from)) { - l_iter = l_chain->callback_atom_find_by_hash(l_sync_request->chain.request_atom_iter, + (void ) l_chain->callback_atom_find_by_hash(l_sync_request->chain.request_atom_iter, &l_sync_request->request.hash_from, &l_first_size); } -- GitLab