Limit the number of connection attempts to avoid endless looping
Non-windows platforms, where the service is not auto-activated, will endless loop until the smartcard service is started. Limit the number of attempts to avoid this. Signed-off-by: Stefan Knoblich <stkn@bitplumber.de>
This commit is contained in:
@@ -67,7 +67,7 @@ PCSCLite::PCSCLite(): m_card_context(0),
|
|||||||
postServiceCheck:
|
postServiceCheck:
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
LONG result;
|
LONG result, attempt = 0;
|
||||||
// TODO: consider removing this do-while Windows workaround that should not be needed anymore
|
// TODO: consider removing this do-while Windows workaround that should not be needed anymore
|
||||||
do {
|
do {
|
||||||
// TODO: make dwScope (now hard-coded to SCARD_SCOPE_SYSTEM) customisable
|
// TODO: make dwScope (now hard-coded to SCARD_SCOPE_SYSTEM) customisable
|
||||||
@@ -75,7 +75,7 @@ postServiceCheck:
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&m_card_context);
|
&m_card_context);
|
||||||
} while(result == SCARD_E_NO_SERVICE || result == SCARD_E_SERVICE_STOPPED);
|
} while((result == SCARD_E_NO_SERVICE || result == SCARD_E_SERVICE_STOPPED) && ++attempt <= 10);
|
||||||
if (result != SCARD_S_SUCCESS) {
|
if (result != SCARD_S_SUCCESS) {
|
||||||
Nan::ThrowError(error_msg("SCardEstablishContext", result).c_str());
|
Nan::ThrowError(error_msg("SCardEstablishContext", result).c_str());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user