Diff

Differences From Artifact [b583369d4a]:

To Artifact [f4c949a3a4]:


    10     10   
    11     11   /*
    12     12    * Handle for the CACKey NaCl Target
    13     13    */
    14     14   var cackeyHandle = null;
    15     15   var cackeyPCSCHandle = null;
    16     16   var cackeyPCSCHandleUsable = false;
           17  +var cackeyPCSCHandleLastUsed = (new Date()).getTime();
    17     18   
    18     19   /*
    19     20    * Handle and ID for outstanding callbacks
    20     21    */
    21     22   var cackeyOutstandingCallbacks = {}
    22     23   var cackeyOutstandingCallbackCounter = -1;
    23     24   
................................................................................
   539    540    */
   540    541   function cackeyUninitPCSC() {
   541    542   	console.log("[cackey] cackeyUninitPCSC() called");
   542    543   
   543    544   	if (cackeyPCSCHandle != null) {
   544    545   		console.log("[cackey] Deleting PCSC handle");
   545    546   
   546         -		delete cackeyPCSCHandle;
   547         -
   548    547   		cackeyPCSCHandle = null;
   549    548   	}
   550    549   
   551    550   	cackeyPCSCHandleUsable = false;
   552    551   
   553    552   	console.log("[cackey] cackeyUninitPCSC() returning");
   554    553   
................................................................................
   669    668   /*
   670    669    * Initialize the PCSC connection
   671    670    */
   672    671   function cackeyInitPCSC(callbackAfterInit, callbackInitFailed) {
   673    672   	/*
   674    673   	 * Start the Google PCSC Interface
   675    674   	 */
          675  +	var now, lastUsedMillisecondsAgo;
   676    676   
   677    677   	console.log("[cackey] cackeyInitPCSC() called");
   678    678   
          679  +	now = (new Date()).getTime();
          680  +	lastUsedMillisecondsAgo = now - cackeyPCSCHandleLastUsed;
          681  +
          682  +	if (lastUsedMillisecondsAgo > 30000) {
          683  +		console.log("[cackey] PCSC handle was last used " + lastUsedMillisecondsAgo + "ms ago, restarting to get a new handle");
          684  +		cackeyRestart();
          685  +	}
          686  +
          687  +	cackeyPCSCHandleLastUsed = now;
          688  +
   679    689   	/*
   680    690   	 * Queue this callback to be completed when initialization is complete
   681    691   	 */
   682    692   	if (callbackAfterInit) {
   683    693   		cackeyCallbackAfterInit.push({"successCallback": callbackAfterInit, "failureCallback": callbackInitFailed});
   684    694   	}
   685    695