File tree Expand file tree Collapse file tree 1 file changed +9
-21
lines changed Expand file tree Collapse file tree 1 file changed +9
-21
lines changed Original file line number Diff line number Diff line change @@ -67,10 +67,13 @@ def _read_from_socket(nbytes)
6767 end
6868 end
6969
70- def _write_to_socket ( data )
70+ def write ( buffer )
71+ return super ( buffer ) unless @write_timeout
72+
73+ bytes_to_write = buffer . bytesize
7174 total_bytes_written = 0
7275 loop do
73- case bytes_written = write_nonblock ( data , exception : false )
76+ case bytes_written = write_nonblock ( buffer , exception : false )
7477 when :wait_readable
7578 unless wait_readable ( @write_timeout )
7679 raise Redis ::TimeoutError
@@ -83,28 +86,13 @@ def _write_to_socket(data)
8386 raise Errno ::ECONNRESET
8487 when Integer
8588 total_bytes_written += bytes_written
86- if bytes_written < data . bytesize
87- data . slice! ( 0 , bytes_written )
88- else
89+
90+ if total_bytes_written >= bytes_to_write
8991 return total_bytes_written
9092 end
91- end
92- end
93- end
9493
95- def write ( data )
96- return super ( data ) unless @write_timeout
97-
98- data = data . b
99- length = data . bytesize
100- total_count = 0
101- loop do
102- count = _write_to_socket ( data )
103-
104- total_count += count
105- return total_count if total_count >= length
106-
107- data = data . byteslice ( count ..-1 )
94+ buffer = buffer . byteslice ( bytes_written ..-1 )
95+ end
10896 end
10997 end
11098 end
You can’t perform that action at this time.
0 commit comments