Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/adapter/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,37 @@ inline static void reply(neu_adapter_t *adapter, neu_reqresp_head_t *header,
inline static void notify_monitor(neu_adapter_t * adapter,
neu_reqresp_type_e event, void *data);

static void dedup_add_tag_results_by_index(neu_resp_add_tag_t *resp)
{
if (resp == NULL || resp->results == NULL) {
return;
}

size_t n_results = utarray_len(resp->results);
if (n_results < 2) {
return;
}

for (size_t i = 0; i < n_results; i++) {
neu_resp_tag_op_result_t *current =
(neu_resp_tag_op_result_t *) utarray_eltptr(resp->results, i);
if (current == NULL) {
continue;
}

for (size_t j = i + 1; j < n_results;) {
neu_resp_tag_op_result_t *candidate =
(neu_resp_tag_op_result_t *) utarray_eltptr(resp->results, j);
if (candidate != NULL && candidate->index == current->index) {
utarray_erase(resp->results, j, 1);
n_results--;
continue;
}
j++;
}
}
}

static const adapter_callbacks_t callback_funs = {
.command = adapter_command,
.response = adapter_response,
Expand Down Expand Up @@ -1611,6 +1642,7 @@ static int adapter_loop(enum neu_event_io_type type, int fd, void *usr_data)
neu_msg_exchange(header);
header->type = NEU_RESP_ADD_TAG;
free(cmd->tags);
dedup_add_tag_results_by_index(&resp);
reply(adapter, header, &resp);
break;
}
Expand All @@ -1631,6 +1663,7 @@ static int adapter_loop(enum neu_event_io_type type, int fd, void *usr_data)

neu_msg_exchange(header);
header->type = NEU_RESP_ADD_TAG;
dedup_add_tag_results_by_index(&resp);
reply(adapter, header, &resp);
break;
}
Expand Down
Loading