Skip to content

Commit

Permalink
DAOS-12961 cart: return error if crt_provider_get_ctx_idx() failed (#…
Browse files Browse the repository at this point in the history
…13263)

Fix to return error for crt_provider_get_ctx_idx(), so we don't need
call crt_provider_put_ctx_idx() if it failed to avoid assertion in crt_finalize().

Signed-off-by: Wang Shilong <[email protected]>
  • Loading branch information
wangshilong authored Nov 6, 2023
1 parent cf57ca9 commit a57d580
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/cart/crt_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ crt_context_provider_create(crt_context_t *crt_ctx, crt_provider_t provider, boo
}

D_RWLOCK_WRLOCK(&crt_gdata.cg_rwlock);
max_ctx_num = crt_provider_get_max_ctx_num(primary, provider);
ctx_idx = crt_provider_get_ctx_idx(primary, provider);

if (ctx_idx < 0 || ctx_idx >= max_ctx_num) {
if (ctx_idx < 0) {
max_ctx_num = crt_provider_get_max_ctx_num(primary, provider);
D_WARN("Provider: %d; Context limit (%d) reached\n",
provider, max_ctx_num);
D_RWLOCK_UNLOCK(&crt_gdata.cg_rwlock);
Expand Down
2 changes: 1 addition & 1 deletion src/cart/crt_hg.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ crt_provider_get_ctx_idx(bool primary, int provider)
struct crt_prov_gdata *prov_data = crt_get_prov_gdata(primary, provider);
int i;

for (i = 0; i < CRT_SRV_CONTEXT_NUM; i++) {
for (i = 0; i < prov_data->cpg_ctx_max_num; i++) {
if (prov_data->cpg_used_idx[i] == false) {
prov_data->cpg_used_idx[i] = true;
prov_data->cpg_ctx_num++;
Expand Down

0 comments on commit a57d580

Please sign in to comment.