@@ -38,11 +38,11 @@ var cackeyCertificateToPINMap = {}; /* * Callbacks to perform after PCSC comes online */ -cackeyCallbackAfterInit = [] +cackeyCallbackAfterInit = []; /* * Compute a text-based handle for a certificate to be hashed by */ function cackeyCertificateToPINID(certificate) { @@ -464,19 +464,33 @@ cackeyInit(); return; } +function cackeyInitGlobalState() { + cackeyOutstandingCallbacks = {}; +}; + /* * Handle a CACKey crash (probably due to loss of connectivity to the PCSC daemon) */ function cackeyCrash() { + /* + * De-initialize CACKey + */ + cackeyUninit(); + + /* + * Reinitialize global state + */ + cackeyInitGlobalState(); + /* * Schedule the restart to occur in 30 seconds in case we really are * not working. */ - setTimeout(cackeyRestart, 30000); + setTimeout(cackeyInit, 30000); return; } function cackeyInitPCSCCompleted() { @@ -681,11 +695,16 @@ cackeyInitPCSCCompleted(); return; }; + /* + * Initialize global state + */ + cackeyInitGlobalState(); + return; } /* Initialize CACKey */ cackeyAppInit(); cackeyInit();