diff --git a/modules/channel/chain-net-srv/dap_stream_ch_chain_net_srv.c b/modules/channel/chain-net-srv/dap_stream_ch_chain_net_srv.c index 742271b5612c855b4d84d4163ace24004f0ea7b0..27629e395411f8a7ae6a61f43de8adb8b79165b9 100644 --- a/modules/channel/chain-net-srv/dap_stream_ch_chain_net_srv.c +++ b/modules/channel/chain-net-srv/dap_stream_ch_chain_net_srv.c @@ -821,13 +821,13 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch , void* a_arg) // Update actual receipt bool l_is_first_sign = false; if (! l_usage->receipt_next && l_usage->receipt){ - DAP_DELETE(l_usage->receipt); + DAP_DEL_Z(l_usage->receipt); l_usage->receipt = DAP_NEW_SIZE(dap_chain_datum_tx_receipt_t,l_receipt_size); l_is_first_sign = true; l_usage->is_active = true; memcpy( l_usage->receipt, l_receipt, l_receipt_size); } else if (l_usage->receipt_next ){ - DAP_DELETE(l_usage->receipt_next); + DAP_DEL_Z(l_usage->receipt_next); l_usage->receipt_next = DAP_NEW_SIZE(dap_chain_datum_tx_receipt_t,l_receipt_size); l_usage->is_active = true; memcpy( l_usage->receipt_next, l_receipt, l_receipt_size); @@ -1012,21 +1012,26 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch , void* a_arg) char *l_tx_in_hash_str = dap_chain_hash_fast_to_str_new(&l_responce->hdr.tx_cond); log_it(L_NOTICE, "Received new tx cond %s", l_tx_in_hash_str); DAP_DELETE(l_tx_in_hash_str); - l_usage->is_waiting_new_tx_cond = false; + if(!l_usage->is_waiting_new_tx_cond || !l_usage->is_grace) + break; + + l_usage->is_waiting_new_tx_cond = false; + dap_stream_ch_chain_net_srv_pkt_error_t l_err = { }; usages_in_grace_t *l_curr_grace_item = NULL; pthread_mutex_lock(&s_ht_grace_table_mutex); HASH_FIND(hh, s_grace_table, &l_usage->tx_cond_hash, sizeof(dap_hash_fast_t), l_curr_grace_item); pthread_mutex_unlock(&s_ht_grace_table_mutex); -// if (dap_hash_fast_compare(&l_responce->hdr.tx_cond, &l_usage->tx_cond_hash) || !l_usage->is_grace){ //check new tx not equals to old tx or tx waiting grace period is over -// // if equals delete receipt and tx and stop grace if running -// if (l_curr_grace_item){ -// HASH_DEL(s_grace_table, l_curr_grace_item); -// dap_timerfd_delete_mt(l_curr_grace_item->grace->stream_worker->worker, l_curr_grace_item->grace->timer_es_uuid); -// } -// break; -// } + if (dap_hash_fast_is_blank(&l_responce->hdr.tx_cond)){ //if new tx cond creation failed tx_cond in responce will be blank + if (l_curr_grace_item){ + HASH_DEL(s_grace_table, l_curr_grace_item); + dap_timerfd_delete_mt(l_curr_grace_item->grace->stream_worker->worker, l_curr_grace_item->grace->timer_es_uuid); + s_grace_error(l_curr_grace_item->grace, l_err); + DAP_DEL_Z(l_curr_grace_item); + } + break; + } dap_chain_datum_tx_t *l_tx = dap_chain_ledger_tx_find_by_hash(l_usage->net->pub.ledger, &l_responce->hdr.tx_cond); if (l_tx){ diff --git a/modules/net/srv/dap_chain_net_srv_stream_session.c b/modules/net/srv/dap_chain_net_srv_stream_session.c index 5a5d8e99e744fbc8b582b94d34c73913bc89a350..98136f6fbcfbdf72f7fd82ac7e4694c00048ad69 100644 --- a/modules/net/srv/dap_chain_net_srv_stream_session.c +++ b/modules/net/srv/dap_chain_net_srv_stream_session.c @@ -100,9 +100,9 @@ void dap_chain_net_srv_usage_delete (dap_chain_net_srv_stream_session_t * a_srv_ return; if ( a_srv_session->usage_active->receipt ) - DAP_DELETE( a_srv_session->usage_active->receipt ); + DAP_DEL_Z( a_srv_session->usage_active->receipt ); if ( a_srv_session->usage_active->receipt_next ) - DAP_DELETE( a_srv_session->usage_active->receipt_next ); + DAP_DEL_Z( a_srv_session->usage_active->receipt_next); if ( a_srv_session->usage_active->client ){ for (dap_chain_net_srv_client_remote_t * l_srv_client = a_srv_session->usage_active->client, * tmp = NULL; l_srv_client; ){ tmp = l_srv_client; diff --git a/modules/service/vpn/dap_chain_net_srv_vpn.c b/modules/service/vpn/dap_chain_net_srv_vpn.c index b2ff5ae724d0851897898eaf962219a03cdd4379..41f000cce27399c095ddaba5a7f2a41893bc50d0 100644 --- a/modules/service/vpn/dap_chain_net_srv_vpn.c +++ b/modules/service/vpn/dap_chain_net_srv_vpn.c @@ -1188,7 +1188,7 @@ static void s_update_limits(dap_stream_ch_t * a_ch , if( a_srv_session->limits_ts <= 0 && !a_usage->is_grace){ log_it(L_INFO, "Limits by timestamp are over. Switch to the next receipt"); - DAP_DELETE(a_usage->receipt); + DAP_DEL_Z(a_usage->receipt); a_usage->receipt = a_usage->receipt_next; a_usage->receipt_next = NULL; if ( a_usage->receipt){ // If there is next receipt add the time and request the next receipt @@ -1245,7 +1245,7 @@ static void s_update_limits(dap_stream_ch_t * a_ch , if (a_srv_session->limits_bytes <= 0 && !a_usage->is_grace){ log_it(L_INFO, "Limits by traffic is over. Switch to the next receipt"); - DAP_DELETE(a_usage->receipt); + DAP_DEL_Z(a_usage->receipt); a_usage->receipt = a_usage->receipt_next; a_usage->receipt_next = NULL; if ( a_usage->receipt){ // If there is next receipt add the time and request the next receipt