Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

buf -> tmp

  • Loading branch information...
commit 1a1057a440ee82e52ab060acde0e0985b021c03e 1 parent 47002f9
@tj authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 lib/connection.js
View
28 lib/connection.js
@@ -33,8 +33,8 @@ var stub = {
var Connection = module.exports = function Connection(server, stream) {
this.server = server;
this.state = 'request';
- this.buf = new Buffer(128);
- this.buf.pos = 0;
+ this.tmp = new Buffer(256);
+ this.tmp.pos = 0;
this.stream = stream || stub;
this.stream.on('data', this.parse.bind(this));
};
@@ -107,7 +107,7 @@ Connection.prototype.protocolError = function(msg){
Connection.prototype.error = function(msg){
this.stream.write('-ERR ' + msg + '\r\n');
this.state = 'request';
- this.buf.pos = 0;
+ this.tmp.pos = 0;
this.multiple = null;
this.cmd = null;
return true;
@@ -201,9 +201,9 @@ Connection.prototype.invoke = function(cmd, args){
Connection.prototype.bufferArgument = function(){
// Push argument Buffer
- var len = this.buf.pos
+ var len = this.tmp.pos
, arg = new Buffer(len);
- this.buf.copy(arg, 0, 0, len);
+ this.tmp.copy(arg, 0, 0, len);
arg.pos = len;
this.args.push(arg);
};
@@ -214,7 +214,7 @@ Connection.prototype.bufferArgument = function(){
Connection.prototype.bufferCommand = function(){
var fn;
- this.cmd = string(this.buf).toLowerCase();
+ this.cmd = string(this.tmp).toLowerCase();
// Command is valid
if (fn = commands[this.cmd]) {
var multiple = this.multiple = fn.multiple
@@ -293,7 +293,7 @@ Connection.prototype.parse = function(buf){
this.state = 'multi bulk lf';
// n
} else {
- this.buf[this.buf.pos++] = buf[pos];
+ this.tmp[this.tmp.pos++] = buf[pos];
}
++pos;
break;
@@ -306,12 +306,12 @@ Connection.prototype.parse = function(buf){
// \n
if (10 == buf[pos++]) {
this.state = 'request';
- this.multiBulkCount = +string(this.buf);
+ this.multiBulkCount = +string(this.tmp);
this.multiBulkReceived = 0;
if (isNaN(this.multiBulkCount)) {
return this.protocolError('number expected after *');
}
- this.buf.pos = 0;
+ this.tmp.pos = 0;
// Error
} else {
return this.error('missing line feed for multi-bulk count');
@@ -328,7 +328,7 @@ Connection.prototype.parse = function(buf){
this.state = 'bulk lf';
// n
} else {
- this.buf[this.buf.pos++] = buf[pos];
+ this.tmp[this.tmp.pos++] = buf[pos];
}
++pos;
break;
@@ -340,12 +340,12 @@ Connection.prototype.parse = function(buf){
case 'bulk lf':
// \n
if (10 == buf[pos++]) {
- this.bulkLength = +string(this.buf);
+ this.bulkLength = +string(this.tmp);
if (isNaN(this.bulkLength)) {
return this.protocolError('number expected after $');
}
this.bulkReceived = 0;
- this.buf.pos = 0;
+ this.tmp.pos = 0;
this.state = 'data';
// Error
} else {
@@ -376,7 +376,7 @@ Connection.prototype.parse = function(buf){
return this.error('missing carriage return for bulk data');
}
} else {
- this.buf[this.buf.pos++] = buf[pos++];
+ this.tmp[this.tmp.pos++] = buf[pos++];
}
break;
@@ -392,7 +392,7 @@ Connection.prototype.parse = function(buf){
this.invoke(this.cmd, this.args);
}
this.state = 'request';
- this.buf.pos = 0;
+ this.tmp.pos = 0;
// Error
} else {
return this.error('missing line feed for bulk data');
Please sign in to comment.
Something went wrong with that request. Please try again.