Skip to content
Snippets Groups Projects
Commit 53b61a8c authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

net.box: optimize write buffering

parent 7f8a9a70
No related branches found
No related tags found
No related merge requests found
...@@ -592,7 +592,7 @@ local remote_methods = { ...@@ -592,7 +592,7 @@ local remote_methods = {
self:_switch_state('error') self:_switch_state('error')
self:_error_waiters(emsg) self:_error_waiters(emsg)
self.rbuf = '' self.rbuf = ''
self.wbuf = '' self.wbuf = {}
self.handshake = '' self.handshake = ''
end, end,
...@@ -791,7 +791,7 @@ local remote_methods = { ...@@ -791,7 +791,7 @@ local remote_methods = {
elseif string.len(self.handshake) ~= 128 then elseif string.len(self.handshake) ~= 128 then
self:_fatal("Can't read handshake") self:_fatal("Can't read handshake")
else else
self.wbuf = '' self.wbuf = {}
self.rbuf = '' self.rbuf = ''
if string.match(self.handshake, '^Tarantool .*console') then if string.match(self.handshake, '^Tarantool .*console') then
...@@ -985,7 +985,7 @@ local remote_methods = { ...@@ -985,7 +985,7 @@ local remote_methods = {
break break
end end
if string.len(self.wbuf) == 0 then if self.wbuf[1] == nil then
local wstate = self._to_rstate[self.state] local wstate = self._to_rstate[self.state]
if wstate ~= nil then if wstate ~= nil then
...@@ -998,12 +998,17 @@ local remote_methods = { ...@@ -998,12 +998,17 @@ local remote_methods = {
break break
end end
if self:_is_rw_state() then if self:_is_rw_state() then
if #self.wbuf > 0 then if self.wbuf[1] ~= nil then
local written = self.s:syswrite(self.wbuf) local s = table.concat(self.wbuf)
self.wbuf = {}
local written = self.s:syswrite(s)
if written ~= nil then if written ~= nil then
self.wbuf = string.sub(self.wbuf, if written ~= #s then
tonumber(1 + written)) table.insert(self.wbuf,
string.sub(s, written + 1))
end
else else
table.insert(self.wbuf, s)
self:_fatal(errno.strerror(errno())) self:_fatal(errno.strerror(errno()))
end end
end end
...@@ -1062,7 +1067,7 @@ local remote_methods = { ...@@ -1062,7 +1067,7 @@ local remote_methods = {
self.timeouts[fid] = TIMEOUT_INFINITY self.timeouts[fid] = TIMEOUT_INFINITY
end end
self.wbuf = self.wbuf .. request table.insert(self.wbuf, request)
local wstate = self._to_wstate[self.state] local wstate = self._to_wstate[self.state]
if wstate ~= nil then if wstate ~= nil then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment