Permalink
Browse files

Fixed buffer race condition.

  • Loading branch information...
1 parent 6d49361 commit 988a8c7e61781a0d7f3bfb6ba9a144478957406c @Trakkasure committed Jun 27, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/index.js
View
@@ -505,15 +505,16 @@ function Channel(instance) {
instance.commands.push([this.buffer,writeCallback]);
this.buffer=[];
} else {
+ var b=this.buffer;
+ this.buffer=[];
+ b.push('.tag='+this.getId());
this.running(true);
this.saveBuffer(true);
this.callback=writeCallback;
this.callback(this); // allow setup before sending command.
this.callback=null;
- this.buffer.push('.tag='+this.getId());
- if (this.getConnection().debug>0) util.debug('Channel ('+this.getConnection().getHost()+":"+this.getId()+') write lines: '+this.buffer.join("\n"));
- this.getConnection().write(this.buffer); // Send command.
- this.buffer=[];
+ if (this.getConnection().debug>0) util.debug('Channel ('+this.getConnection().getHost()+":"+this.getId()+') write lines: '+b.join("\n"));
+ this.getConnection().write(b); // Send command.
}
},
done: function(data) { // Don't call instance directly. This is called when the data stream is complete for instance channel.

0 comments on commit 988a8c7

Please sign in to comment.