Improves the RSA sign async accelerator.
Ylian Saint-Hilaire committed
May 3, 2019 at 09:59 UTC
2ea763ea83bdee3585de806949c906570bfe19d6
1 file changed
+11
-13
certoperations.js
+11
-13
@@ -598,16 +598,16 @@ module.exports.CertificateOperations = function (parent) {
598
accelerator.accid = acceleratorCreateCount;
599
accelerator.on("message", function (message) {
600
acceleratorMessage++;
601
- try { this.func(this.tag, message); } catch (ex) { acceleratorMessageException++; acceleratorMessageLastException = ex; }
602
- try {
603
- delete this.tag;
604
- if (pendingAccelerator.length > 0) {
605
- var x = pendingAccelerator.shift();
606
- if (x.tag) { this.tag = x.tag; delete x.tag; }
607
- accelerator.send(x);
608
- } else { freeAccelerators.push(this); }
609
- } catch (ex) { acceleratorException++; acceleratorLastException = ex; }
601
+ this.x.func(this.x.tag, message);
602
+ delete this.x;
603
+ if (pendingAccelerator.length > 0) { this.send(this.x = pendingAccelerator.shift()); } else { freeAccelerators.push(this); }
604
});
605
+ accelerator.on("exit", function (code) {
606
+ if (this.x) { pendingAccelerator.push(this.x); delete this.x; }
607
+ acceleratorCreateCount++;
608
+ if (pendingAccelerator.length > 0) { var acc = obj.getAccelerator(); acc.send(acc.x = pendingAccelerator.shift()); }
609
+ });
610
+ accelerator.on("error", function (code) { }); // Not sure if somethign should be done here to help kill the process.
611
accelerator.send({ action: "setState", certs: obj.acceleratorCertStore });
612
return accelerator;
613
}
@@ -636,13 +636,11 @@ module.exports.CertificateOperations = function (parent) {
636
if (acc == null) {
637
// Add to pending accelerator workload
638
acceleratorPerformSignaturePushFuncCall++;
639
- pendingAccelerator.push({ action: "sign", key: privatekey, data: data, tag: tag });
639
+ pendingAccelerator.push({ action: "sign", key: privatekey, data: data, tag: tag, func: func });
640
} else {
641
// Send to accelerator now
642
acceleratorPerformSignatureRunFuncCall++;
643
- acc.func = func;
644
- acc.tag = tag;
645
- acc.send({ action: "sign", key: privatekey, data: data });
643
+ acc.send(acc.x = { action: "sign", key: privatekey, data: data, tag: tag, func: func });
644
}
645
}
646
};