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)
67
67
end
68
68
end
69
69
70
- def _write_to_socket ( data )
70
+ def write ( buffer )
71
+ return super ( buffer ) unless @write_timeout
72
+
73
+ bytes_to_write = buffer . bytesize
71
74
total_bytes_written = 0
72
75
loop do
73
- case bytes_written = write_nonblock ( data , exception : false )
76
+ case bytes_written = write_nonblock ( buffer , exception : false )
74
77
when :wait_readable
75
78
unless wait_readable ( @write_timeout )
76
79
raise Redis ::TimeoutError
@@ -83,28 +86,13 @@ def _write_to_socket(data)
83
86
raise Errno ::ECONNRESET
84
87
when Integer
85
88
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
89
91
return total_bytes_written
90
92
end
91
- end
92
- end
93
- end
94
93
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
108
96
end
109
97
end
110
98
end
You can’t perform that action at this time.
0 commit comments