From e8f35c0e0fc62ac14d176471fb1e035c15ce7a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 15 Mar 2020 21:01:12 +0100 Subject: [PATCH] Avoid a possible concurrent write to the same socket. --- tests/0-tcp.d | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/0-tcp.d b/tests/0-tcp.d index e7f1760..ebda137 100644 --- a/tests/0-tcp.d +++ b/tests/0-tcp.d @@ -38,12 +38,16 @@ void main() assert(bts == pack1.length); assert(s_rbuf[0 .. pack1.length] == pack1); - print("Second write"); - client.write!((status, bytes) { - print("Second write done"); - assert(status == IOStatus.ok); - assert(bytes == pack2.length); - })(pack2, IOMode.once); + auto tmw = eventDriver.timers.create(); + eventDriver.timers.set(tmw, 20.msecs, 0.msecs); + eventDriver.timers.wait(tmw, (tmw) { + print("Second write"); + client.write!((status, bytes) { + print("Second write done"); + assert(status == IOStatus.ok); + assert(bytes == pack2.length); + })(pack2, IOMode.once); + }); print("Second read"); incoming.read!((status, bts) {