Skip to content

Commit

Permalink
Clear session opening errors on successful re-opening
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Dec 27, 2024
1 parent d7b1339 commit a54521b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ static CK_RV slot_login(P11PROV_SLOT *slot, P11PROV_URI *uri,
}

/* we acquired the session, check that it is ok */
p11prov_set_error_mark(pool->provctx);
ret = session_check(session, session->flags);
if (ret != CKR_OK) {
num_open_sessions--;
Expand All @@ -816,9 +817,13 @@ static CK_RV slot_login(P11PROV_SLOT *slot, P11PROV_URI *uri,
ret = token_session_open(session, flags);
if (ret == CKR_OK) {
num_open_sessions++;
p11prov_pop_error_to_mark(pool->provctx);
} else {
p11prov_clear_last_error_mark(pool->provctx);
goto done;
}
} else {
p11prov_clear_last_error_mark(pool->provctx);
}

if (is_login_state(session->state)) {
Expand Down Expand Up @@ -1008,6 +1013,7 @@ CK_RV p11prov_get_session(P11PROV_CTX *provctx, CK_SLOT_ID *slotid,

ret = fetch_session(pool, flags, false, &session);
if (ret == CKR_OK) {
p11prov_set_error_mark(pool->provctx);
ret = session_check(session, flags);
if (ret != CKR_OK) {
num_open_sessions--;
Expand All @@ -1017,8 +1023,11 @@ CK_RV p11prov_get_session(P11PROV_CTX *provctx, CK_SLOT_ID *slotid,
ret = token_session_open(session, flags);
if (ret == CKR_OK) {
num_open_sessions++;
p11prov_pop_error_to_mark(pool->provctx);
goto done;
}
}
p11prov_clear_last_error_mark(pool->provctx);
}

done:
Expand Down

0 comments on commit a54521b

Please sign in to comment.