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
11
12
13
14
15
16

17
18
19
20
21
22
23

/*
 * Handle for the CACKey NaCl Target
 */
var cackeyHandle = null;
var cackeyPCSCHandle = null;
var cackeyPCSCHandleUsable = false;


/*
 * Handle and ID for outstanding callbacks
 */
var cackeyOutstandingCallbacks = {}
var cackeyOutstandingCallbackCounter = -1;








>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

/*
 * Handle for the CACKey NaCl Target
 */
var cackeyHandle = null;
var cackeyPCSCHandle = null;
var cackeyPCSCHandleUsable = false;
var cackeyPCSCHandleLastUsed = (new Date()).getTime();

/*
 * Handle and ID for outstanding callbacks
 */
var cackeyOutstandingCallbacks = {}
var cackeyOutstandingCallbackCounter = -1;

539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
 */
function cackeyUninitPCSC() {
	console.log("[cackey] cackeyUninitPCSC() called");

	if (cackeyPCSCHandle != null) {
		console.log("[cackey] Deleting PCSC handle");

		delete cackeyPCSCHandle;

		cackeyPCSCHandle = null;
	}

	cackeyPCSCHandleUsable = false;

	console.log("[cackey] cackeyUninitPCSC() returning");








<
<







540
541
542
543
544
545
546


547
548
549
550
551
552
553
 */
function cackeyUninitPCSC() {
	console.log("[cackey] cackeyUninitPCSC() called");

	if (cackeyPCSCHandle != null) {
		console.log("[cackey] Deleting PCSC handle");



		cackeyPCSCHandle = null;
	}

	cackeyPCSCHandleUsable = false;

	console.log("[cackey] cackeyUninitPCSC() returning");

669
670
671
672
673
674
675

676
677
678










679
680
681
682
683
684
685
/*
 * Initialize the PCSC connection
 */
function cackeyInitPCSC(callbackAfterInit, callbackInitFailed) {
	/*
	 * Start the Google PCSC Interface
	 */


	console.log("[cackey] cackeyInitPCSC() called");











	/*
	 * Queue this callback to be completed when initialization is complete
	 */
	if (callbackAfterInit) {
		cackeyCallbackAfterInit.push({"successCallback": callbackAfterInit, "failureCallback": callbackInitFailed});
	}








>



>
>
>
>
>
>
>
>
>
>







668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/*
 * Initialize the PCSC connection
 */
function cackeyInitPCSC(callbackAfterInit, callbackInitFailed) {
	/*
	 * Start the Google PCSC Interface
	 */
	var now, lastUsedMillisecondsAgo;

	console.log("[cackey] cackeyInitPCSC() called");

	now = (new Date()).getTime();
	lastUsedMillisecondsAgo = now - cackeyPCSCHandleLastUsed;

	if (lastUsedMillisecondsAgo > 30000) {
		console.log("[cackey] PCSC handle was last used " + lastUsedMillisecondsAgo + "ms ago, restarting to get a new handle");
		cackeyRestart();
	}

	cackeyPCSCHandleLastUsed = now;

	/*
	 * Queue this callback to be completed when initialization is complete
	 */
	if (callbackAfterInit) {
		cackeyCallbackAfterInit.push({"successCallback": callbackAfterInit, "failureCallback": callbackInitFailed});
	}