Permalink
Browse files

ext-hub: optimize

  • Loading branch information...
1 parent 0d2940e commit 35ab1b52b0230fb44d3f21a70a266a3030adeebf @kaven276 committed Oct 9, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/ext_hub.js
View
@@ -170,20 +170,24 @@ function WPWrapper(id, hostp, maxPendingRpc, desc){
new StreamSpliter(wpSock, 'readInt32BE', onWorkerProxyReply);
function onWorkerProxyReply(proxyResp){
- var len = proxyResp.readInt32BE(0)
- , rpcSeq = proxyResp.readUInt16BE(4)
- ;
+ var len = proxyResp.readInt32BE(0);
if (len === 6) {
wpw.setStatus('exiting', 'wp said he will quit');
wpSock.end();
return;
}
+
+ var rpcSeq = proxyResp.readUInt16BE(4);
+ var traceBack = wpw.rpcLog[rpcSeq];
// logPDU('reply for proxySeq=%d, %s', proxySeq, proxyResp.slice(0, 6).toString('hex'));
- var traceBack = wpw.rpcLog[rpcSeq]
- , oraSock = traceBack.oraSock
+ if (!traceBack) {
+ console.warn('proxySeq:%d have no trace back, may ext-hub restarted and proxy send reply in that break', rpcSeq);
+ return;
+ }
+
+ var oraSock = traceBack.oraSock
, oraSeq = traceBack.oraSeq
;
- if (!traceBack) console.warn('proxySeq:%d have no trace back', rpcSeq);
wpw.recycleRpcSeq(rpcSeq);
proxyResp.writeUInt16BE(oraSeq, 4);
oraSock.write(proxyResp);

0 comments on commit 35ab1b5

Please sign in to comment.