Skip to content

Commit

Permalink
cfgutils: Fix "lock" operations during MI listing
Browse files Browse the repository at this point in the history
* fix missing lock check, causing too many unlocks
* always lock the shv during MI listing, to avoid reading garbage
    (e.g. partial data), as a WRITE is taking place in parallel

(cherry picked from commit 0c9aa6f)
  • Loading branch information
liviuchircu committed Dec 18, 2023
1 parent 8c08020 commit 0abdcf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/cfgutils/shvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ int mi_print_var(sh_var_t *shv, mi_item_t *var_item, int do_locking)
return -1;
}

unlock_shvar(shv);
if (do_locking)
unlock_shvar(shv);
} else {
ival = shv->v.value.n;
if (do_locking)
Expand Down Expand Up @@ -547,7 +548,7 @@ mi_response_t *mi_shvar_get_1(const mi_params_t *params, struct mi_handler *_)
if (!var_obj)
goto error;

if (mi_print_var(shv, var_obj, 0) < 0)
if (mi_print_var(shv, var_obj, 1) < 0)
goto error;

return resp;
Expand Down

0 comments on commit 0abdcf2

Please sign in to comment.