diff --git a/src/cart/crt_context.c b/src/cart/crt_context.c index c632f804964..fdcd73c8ec4 100644 --- a/src/cart/crt_context.c +++ b/src/cart/crt_context.c @@ -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); diff --git a/src/cart/crt_hg.c b/src/cart/crt_hg.c index 464afbb9554..c8777448030 100644 --- a/src/cart/crt_hg.c +++ b/src/cart/crt_hg.c @@ -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++;