From bd32cf26fba6e69e17a9fb525772a0a26548e17d Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Mon, 23 Mar 2015 21:41:58 +0300
Subject: [PATCH] socket: fix a regression I introduced when optimizing sockets
 + timeout

---
 src/lua/bsdsocket.lua | 1 +
 src/lua/net_box.lua   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lua/bsdsocket.lua b/src/lua/bsdsocket.lua
index fffbe93a95..793ae416bc 100644
--- a/src/lua/bsdsocket.lua
+++ b/src/lua/bsdsocket.lua
@@ -713,6 +713,7 @@ socket_methods.write = function(self, octets, timeout)
             if not errno_is_transient[self:errno()] then
                 return false
             end
+            written = 0
         end
 
         if written == string.len(octets) then
diff --git a/src/lua/net_box.lua b/src/lua/net_box.lua
index f824a5c74e..d275ced5ff 100644
--- a/src/lua/net_box.lua
+++ b/src/lua/net_box.lua
@@ -1004,7 +1004,7 @@ local remote_methods = {
                 -- packet on the receiving end, and close the connection.
                 -- Every second sockets we iterate the while loop
                 -- and check the connection state
-                    self.s:writable(1)
+                    while self.s:writable(1) == 0 do end
                 else
                     table.insert(self.wbuf, s)
                     self:_fatal(errno.strerror(errno()))
-- 
GitLab