don't throw exception in destructur when card has been removed
This commit is contained in:
@@ -193,6 +193,8 @@ namespace cryptoki {
|
||||
|
||||
Library::Init::~Init() {
|
||||
CRYPTOLOG("log");
|
||||
/// ignore failure in disconnect, possibly smartcard has
|
||||
/// been removed
|
||||
try {
|
||||
//! calls @c C_Finalize
|
||||
check(_fn->C_Finalize(0), CRYPTOKI_FN_LOG("C_Finalize"));
|
||||
@@ -204,8 +206,10 @@ namespace cryptoki {
|
||||
_lib = 0;
|
||||
#endif
|
||||
_fn = 0;
|
||||
} catch (std::exception& e) {
|
||||
CRYPTOLOG("unloading cryptoki library failed, reason: "+e.what());
|
||||
} catch (...) {
|
||||
if (!std::uncaught_exception()) throw;
|
||||
CRYPTOLOG("unloading cryptoki library failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1559,25 +1559,22 @@ namespace cryptoki {
|
||||
}
|
||||
|
||||
~Session() try {
|
||||
CRYPTOLOG("log "<<(std::uncaught_exception()?"IN EXCEPTION":""));
|
||||
/// ignore failure in disconnect, possibly smartcard has
|
||||
/// been removed
|
||||
try {
|
||||
logout();
|
||||
} catch (const std::exception& x) {
|
||||
CRYPTOLOG("caught: "<<x.what());
|
||||
close();
|
||||
if (!std::uncaught_exception()) throw;
|
||||
} catch (...) {
|
||||
CRYPTOLOG("caught");
|
||||
close();
|
||||
if (!std::uncaught_exception()) throw;
|
||||
}
|
||||
close();
|
||||
} catch (const std::exception& x) {
|
||||
CRYPTOLOG("caught: "<<x.what());
|
||||
if (!std::uncaught_exception()) throw;
|
||||
} catch (...) {
|
||||
CRYPTOLOG("caught");
|
||||
if (!std::uncaught_exception()) throw;
|
||||
}
|
||||
|
||||
/*! @name Comfortable Access
|
||||
@@ -1879,16 +1876,16 @@ namespace cryptoki {
|
||||
}
|
||||
|
||||
~Login() {
|
||||
/// ignore failure in disconnect, possibly smartcard has
|
||||
/// been removed
|
||||
try {
|
||||
//! calls @c C_Logout
|
||||
_session.check(_session._slot.library()->C_Logout
|
||||
(_session._session),
|
||||
CRYPTOKI_FN_LOG("C_Logout"));
|
||||
} catch (const std::exception& x) {
|
||||
if (!std::uncaught_exception()) throw;
|
||||
CRYPTOLOG("ERROR during error cleanup: "<<x.what());
|
||||
} catch (...) {
|
||||
if (!std::uncaught_exception()) throw;
|
||||
CRYPTOLOG("ERROR during error cleanup.");
|
||||
}
|
||||
}
|
||||
|
@@ -219,8 +219,8 @@ namespace pcsc {
|
||||
~Reader() {
|
||||
CRYPTOLOG("Disconnect Reader");
|
||||
_state = SCardDisconnect(_id, SCARD_RESET_CARD);
|
||||
if (!std::uncaught_exception())
|
||||
_connection->check(_state, "disconnect smartcard");
|
||||
/// ignore failure in disconnect, possibly smartcard has
|
||||
/// been removed
|
||||
}
|
||||
|
||||
//! Get reader status.
|
||||
@@ -495,7 +495,8 @@ namespace pcsc {
|
||||
~Connection() {
|
||||
CRYPTOLOG("Close Connection id="<<_id);
|
||||
_state = SCardReleaseContext(_id);
|
||||
if (!std::uncaught_exception()) check("smartcard release context");
|
||||
/// ignore failure in disconnect, possibly smartcard has
|
||||
/// been removed
|
||||
}
|
||||
|
||||
//! Scans for available readers from a specified list of groups.
|
||||
|
Reference in New Issue
Block a user