Skip to content

Commit

Permalink
search: Clear progress before results (#4943)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazarmy authored Feb 27, 2025
1 parent 14d50bb commit 1705dae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions librz/core/cmd/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,11 @@ static RzCmdStatus cmd_core_handle_search_hits(RzCore *core, RzCmdStateOutput *s
return RZ_CMD_STATUS_ERROR;
}

if (rz_config_get_b(core->config, "search.show_progress")) {
// clear last progress notification, if any
rz_cons_clear_line(1);
}

RzListIter *it = NULL;
RzSearchHit *hit = NULL;
const char *cmd_hit = NULL;
Expand Down
9 changes: 6 additions & 3 deletions librz/search/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,17 @@ static void *search_cancel_th(void *user) {
search_ctx_t *ctx = (search_ctx_t *)user;
RzSearchOpt *opt = ctx->opt;

do {
while (true) {
rz_sys_usleep(RZ_SEARCH_CANCEL_CHECK_INTERVAL_USEC);
if (!rz_atomic_bool_get(ctx->loop)) {
break;
}
size_t n_hits = rz_th_queue_size(ctx->hits);
if (opt->cancel_cb(opt->cancel_usr, n_hits, RZ_SEARCH_CANCEL_REGULAR_CHECK)) {
rz_atomic_bool_set(ctx->loop, false);
break;
}
rz_sys_usleep(RZ_SEARCH_CANCEL_CHECK_INTERVAL_USEC);
} while (rz_atomic_bool_get(ctx->loop));
}

return NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion test/db/cmd/cmd_search_z
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,13 @@ RUN

NAME=String Search - ~[0]
FILE=bins/cmd/search/string_encodings/Latin-Lipsum.ascii
ARGS=-1
CMDS=<<EOF
e search.show_progress=true
/z "placerat ut, eu etiam vitae nam"~[0]
EOF
EXPECT=<<EOF
0x000000fa
0x000000fa
EOF
RUN

Expand Down

0 comments on commit 1705dae

Please sign in to comment.