Permalink
Browse files

Handle partial writes with TCPSocket#syswrite

  • Loading branch information...
1 parent ba9cbd5 commit 622508726ca904b3a004fff7dea712cecf42bc70 @rfletcher committed Apr 4, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/redis/connection/ruby.rb
View
12 lib/redis/connection/ruby.rb
@@ -54,9 +54,15 @@ def timeout=(usecs)
end
end
- def write(command)
- @sock.syswrite(build_command(*command).join(COMMAND_DELIMITER))
- end
+ def write(command)
+ command = build_command(*command).join(COMMAND_DELIMITER)
+
+ size = command.size
+ written = 0
+ begin
+ written = written + @sock.syswrite(command[written,size - written])
+ end while written < size
+ end
def read
# We read the first byte using read() mainly because gets() is

0 comments on commit 6225087

Please sign in to comment.