[patches] [PATCH 1/1] test: ensure on_disconnect trigger is called on outstanding reqs

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Mon Feb 12 16:20:17 MSK 2018


Closes #2998

Signed-off-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
---
 test/box/net.box.result   | 43 +++++++++++++++++++++++++++++++++++++++++++
 test/box/net.box.test.lua | 18 ++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/test/box/net.box.result b/test/box/net.box.result
index fcd441856..0a6f118e7 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -2134,6 +2134,49 @@ disconnected -- true
 box.session.on_disconnect(nil, on_disconnect)
 ---
 ...
+--
+-- gh-2998: on_disconnect is not called if a connection is closed
+-- with outstanding requests.
+--
+disconnected = false
+---
+...
+long_fiber = nil
+---
+...
+function set_on_disconnect() box.session.on_disconnect(function() disconnected = true end) end
+---
+...
+function long_poll() long_fiber = fiber.self() fiber.sleep(3000) end
+---
+...
+c = net.connect(box.cfg.listen)
+---
+...
+c:call('set_on_disconnect')
+---
+...
+_ = fiber.create(function() c:call('long_poll') end)
+---
+...
+long_fiber ~= nil
+---
+- true
+...
+c:close()
+---
+...
+disconnected
+---
+- false
+...
+long_fiber:cancel()
+---
+...
+disconnected
+---
+- true
+...
 box.schema.user.revoke('guest', 'execute', 'universe')
 ---
 ...
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index 378dfd4ab..bd5bb9591 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -871,4 +871,22 @@ while disconnected == false do fiber.sleep(0.01) end
 disconnected -- true
 
 box.session.on_disconnect(nil, on_disconnect)
+
+--
+-- gh-2998: on_disconnect is not called if a connection is closed
+-- with outstanding requests.
+--
+disconnected = false
+long_fiber = nil
+function set_on_disconnect() box.session.on_disconnect(function() disconnected = true end) end
+function long_poll() long_fiber = fiber.self() fiber.sleep(3000) end
+
+c = net.connect(box.cfg.listen)
+c:call('set_on_disconnect')
+_ = fiber.create(function() c:call('long_poll') end)
+long_fiber ~= nil
+c:close()
+disconnected
+long_fiber:cancel()
+disconnected
 box.schema.user.revoke('guest', 'execute', 'universe')
-- 
2.14.3 (Apple Git-98)




More information about the Tarantool-patches mailing list