Check-in [75e6e54b71]
Overview
Comment:Periodically restart CACKey if PC/SC handle has not been used in a while
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:75e6e54b71bb7c009162f9babf41b644ffc2fc14
User & Date: rkeene on 2019-01-30 18:35:50
Other Links: manifest | tags
Context
2019-01-30
18:36
ChromeOS Release 10 check-in: a0a37b2628 user: rkeene tags: trunk
18:35
Periodically restart CACKey if PC/SC handle has not been used in a while check-in: 75e6e54b71 user: rkeene tags: trunk
17:47
Whitespace cleanup check-in: 90921f9444 user: rkeene tags: trunk
Changes

Modified build/chrome/cackey.js from [b583369d4a] to [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