diff --git a/dap-sdk/net/stream/ch/dap_stream_ch.c b/dap-sdk/net/stream/ch/dap_stream_ch.c index 8a93a0106ff1c9817ef62f808aefd3c11c492e08..873a31d228905a32eaf281d0788572d273a400de 100644 --- a/dap-sdk/net/stream/ch/dap_stream_ch.c +++ b/dap-sdk/net/stream/ch/dap_stream_ch.c @@ -103,6 +103,7 @@ dap_stream_ch_t* dap_stream_ch_new(dap_stream_t* a_stream, uint8_t id) pthread_rwlock_unlock(&a_stream->rwlock); struct dap_stream_ch_table_t *l_new_ch = DAP_NEW_Z(struct dap_stream_ch_table_t); + l_new_ch->ch = ret; pthread_mutex_lock(&s_ch_table_lock); HASH_ADD_PTR(s_ch_table, ch, l_new_ch); pthread_mutex_unlock(&s_ch_table_lock); @@ -118,7 +119,7 @@ bool dap_stream_ch_valid(dap_stream_ch_t *a_ch) { struct dap_stream_ch_table_t *l_ret; pthread_mutex_lock(&s_ch_table_lock); - HASH_FIND_PTR(s_ch_table, a_ch, l_ret); + HASH_FIND_PTR(s_ch_table, &a_ch, l_ret); pthread_mutex_unlock(&s_ch_table_lock); return l_ret; } @@ -131,13 +132,14 @@ void dap_stream_ch_delete(dap_stream_ch_t *a_ch) { pthread_mutex_lock(&s_ch_table_lock); struct dap_stream_ch_table_t *l_ret;; - HASH_FIND_PTR(s_ch_table, a_ch, l_ret); + HASH_FIND_PTR(s_ch_table, &a_ch, l_ret); if (!l_ret) { pthread_mutex_unlock(&s_ch_table_lock); return; } HASH_DEL(s_ch_table, l_ret); pthread_mutex_unlock(&s_ch_table_lock); + DAP_DELETE(l_ret); pthread_mutex_lock(&a_ch->mutex); if (a_ch->proc) diff --git a/modules/channel/chain/dap_stream_ch_chain.c b/modules/channel/chain/dap_stream_ch_chain.c index 90489e339f9499432b432f230f99386eb3e0480b..247ab91a2921dc3648a34eee0afc1435ceedb282 100644 --- a/modules/channel/chain/dap_stream_ch_chain.c +++ b/modules/channel/chain/dap_stream_ch_chain.c @@ -513,7 +513,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) case DAP_STREAM_CH_CHAIN_PKT_TYPE_SYNC_GLOBAL_DB_RVRS: { dap_stream_ch_chain_sync_request_t l_sync_gdb = {}; memcpy(&l_sync_gdb, l_chain_pkt->data, l_chain_pkt_data_size); - dap_chain_net_t *l_net = dap_chain_net_by_id(l_ch_chain->request_net_id); + dap_chain_net_t *l_net = dap_chain_net_by_id(l_chain_pkt->hdr.net_id); l_sync_gdb.node_addr.uint64 = dap_chain_net_get_cur_addr(l_net) ? dap_chain_net_get_cur_addr(l_net)->uint64 : dap_db_get_cur_node_addr(l_net->pub.name); diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index b1fb31ee51129966288237deef8f022791a37fa4..b5bd7e08dbe18ade3d0edaf0fcd19869115277bb 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -1741,6 +1741,9 @@ char * dap_chain_net_get_gdb_group_mempool_by_chain_type(dap_chain_net_t * l_net */ dap_chain_node_addr_t * dap_chain_net_get_cur_addr( dap_chain_net_t * l_net) { + if (!l_net) { + return NULL; + } return PVT(l_net)->node_info ? &PVT(l_net)->node_info->hdr.address : PVT(l_net)->node_addr; }