Permalink
Browse files

Fixed Issue #40

  • Loading branch information...
1 parent f2ce7ba commit 4b0b8cc82dd18b74ecb92bd06150287b2d456a33 @tammofreese committed Jul 19, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/em-mongo/connection.rb
View
8 lib/em-mongo/connection.rb
@@ -164,9 +164,11 @@ def receive_data(data)
end
if @buffer.more?
- remaining_bytes= @buffer.size-@buffer.position
- @buffer = BSON::ByteBuffer.new(@buffer.to_s[@buffer.position,remaining_bytes])
- @buffer.rewind
+ if @buffer.position > 0
+ remaining_bytes= @buffer.size-@buffer.position
+ @buffer = BSON::ByteBuffer.new(@buffer.to_s[@buffer.position,remaining_bytes])
+ @buffer.rewind
+ end
else
@buffer.clear
end

0 comments on commit 4b0b8cc

Please sign in to comment.