diff --git a/modules/channel/chain/dap_stream_ch_chain.c b/modules/channel/chain/dap_stream_ch_chain.c index b60d4678d704dd116c7ae5bd1357aee09f1c5d14..be041c9fcfaad49b7e153e949aa986d49afc316b 100644 --- a/modules/channel/chain/dap_stream_ch_chain.c +++ b/modules/channel/chain/dap_stream_ch_chain.c @@ -634,13 +634,11 @@ static void s_gdb_sync_tsd_worker_callback(dap_worker_t *a_worker, void *a_arg) * @param group_name * @return dap_chain_t* */ -dap_chain_t *s_chain_get_chain_from_group_name(dap_chain_net_id_t net_id, char *group_name) +dap_chain_t *dap_chain_get_chain_from_group_name(dap_chain_net_id_t net_id, const char *group_name) { - dap_chain_t *l_chain; - if (!group_name) { - log_it(L_ERROR, "s_chain_get_chain_id_from_group. GDB group name is NULL"); + log_it(L_ERROR, "GDB group name is NULL "); return NULL; } @@ -649,12 +647,32 @@ dap_chain_t *s_chain_get_chain_from_group_name(dap_chain_net_id_t net_id, char * if (!l_net) return false; + dap_chain_t *l_chain; + DL_FOREACH(l_net->pub.chains, l_chain) { char *s_chain_group_name = dap_chain_net_get_gdb_group_from_chain(l_chain); if (!strcmp(group_name,s_chain_group_name)) + { + DAP_DELETE(s_chain_group_name); return l_chain; + } + DAP_DELETE(s_chain_group_name); + + // + // if we don't get GDB group name, we get it from mempool group + // + + s_chain_group_name = dap_chain_net_get_gdb_group_mempool(l_chain); + + if (!strcmp(group_name,s_chain_group_name)) + { + DAP_DELETE(s_chain_group_name); + return l_chain; + } + + DAP_DELETE(s_chain_group_name); } return NULL; @@ -764,7 +782,7 @@ static bool s_gdb_in_pkt_proc_callback(dap_proc_thread_t *a_thread, void *a_arg) // if chain is zero, it can be on of GDB group // if (!l_chain) - l_chain = s_chain_get_chain_from_group_name(l_sync_request->request_hdr.net_id, l_obj->group); + l_chain = dap_chain_get_chain_from_group_name(l_sync_request->request_hdr.net_id, l_obj->group); if(l_chain) { if(l_chain->callback_add_datums_with_group){ diff --git a/modules/channel/chain/include/dap_stream_ch_chain.h b/modules/channel/chain/include/dap_stream_ch_chain.h index 45fb3c6c749275aa71310dcda4728e462386bff6..82dc678168b5d3c643c6d6a43a24cc3f130463a9 100644 --- a/modules/channel/chain/include/dap_stream_ch_chain.h +++ b/modules/channel/chain/include/dap_stream_ch_chain.h @@ -92,4 +92,5 @@ void dap_stream_ch_chain_deinit(void); inline static uint8_t dap_stream_ch_chain_get_id(void) { return (uint8_t) 'C'; } void dap_stream_ch_chain_go_idle ( dap_stream_ch_chain_t * a_ch_chain); +dap_chain_t * dap_chain_get_chain_from_group_name(dap_chain_net_id_t net_id, const char *group_name); void dap_stream_ch_chain_create_sync_request_gdb(dap_stream_ch_chain_t * a_ch_chain, dap_chain_net_t * a_net); diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 5f48f98dced0479ba4a731933ec9f913beb7f546..04848913bb44b6501538a527f19f010237bdab3f 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -433,7 +433,15 @@ void dap_chain_net_sync_gdb_broadcast(void *a_arg, const char a_op_code, const c } dap_store_obj_pkt_t *l_data_out = dap_store_packet_single(l_obj); dap_store_obj_free(l_obj, 1); - dap_chain_t *l_chain = dap_chain_net_get_chain_by_name(l_net, "gdb"); + dap_chain_t *l_chain = dap_chain_get_chain_from_group_name(l_net->pub.id, a_group); + + if (!l_chain) + { + log_it(L_WARNING, "chain object is not found for group %s", a_group); + DAP_DELETE(l_data_out); + return; + } + dap_chain_id_t l_chain_id = l_chain ? l_chain->id : (dap_chain_id_t) {}; dap_chain_cell_id_t l_cell_id = l_chain ? l_chain->cells->id : (dap_chain_cell_id_t){}; pthread_rwlock_rdlock(&PVT(l_net)->rwlock);