Permalink
Browse files

db.js use var slot to save arr[idx]

  • Loading branch information...
1 parent df383d3 commit 988bfe87661cc8c38b6d81b213f4b804bb1415b0 @kaven276 committed Sep 28, 2012
Showing with 9 additions and 7 deletions.
  1. +9 −7 lib/db.js
View
@@ -79,11 +79,12 @@ var dbListener = net.createServer({allowHalfOpen : true}, function(c){
}
logger.db('oracle server(%d:%d) connected, now has %d', c.sid, c.serial, dbListener.connections);
- if (dbPool[c.pseq]) {
- dbPool[c.pseq].oraSock = c;
- dbPool[c.pseq].status = 'free';
+ var slot = dbPool[c.pseq];
+ if (slot) {
+ slot.oraSock = c;
+ slot.status = 'free';
} else {
- dbPool[c.pseq] = new Slot(c);
+ slot = dbPool[c.pseq] = new Slot(c);
}
freeList.push(c);
@@ -92,9 +93,9 @@ var dbListener = net.createServer({allowHalfOpen : true}, function(c){
c.on('end', function(pos){
logger.db('oracle server(%d:%d) disconnected, now has %d', c.sid, c.serial, dbListener.connections);
- dbPool[c.pseq].hBytesRead += c.bytesRead;
- dbPool[c.pseq].hBytesWritten += c.bytesWritten;
- dbPool[c.pseq].status = 'closed';
+ slot.hBytesRead += c.bytesRead;
+ slot.hBytesWritten += c.bytesWritten;
+ slot.status = 'closed';
pos = find(quitList, c);
if (~pos) {
@@ -201,6 +202,7 @@ function pushBackToFreelist(oraSock, busyRec){
logger.db('push back to %d', oraSock.seq);
oraSock.removeAllListeners('data');
oraSock.removeAllListeners('timeout');
+
// mark this busyRec has no oraSock for use, css/fb depend on it to detect timeout clearup
freeList.unshift(oraSock);
dbPool[oraSock.pseq].status = 'free';

0 comments on commit 988bfe8

Please sign in to comment.