Avoid a possible concurrent write to the same socket.

This commit is contained in:
Sönke Ludwig 2020-03-15 21:01:12 +01:00
parent e66b29d8df
commit e8f35c0e0f

View file

@ -38,12 +38,16 @@ void main()
assert(bts == pack1.length); assert(bts == pack1.length);
assert(s_rbuf[0 .. pack1.length] == pack1); assert(s_rbuf[0 .. pack1.length] == pack1);
auto tmw = eventDriver.timers.create();
eventDriver.timers.set(tmw, 20.msecs, 0.msecs);
eventDriver.timers.wait(tmw, (tmw) {
print("Second write"); print("Second write");
client.write!((status, bytes) { client.write!((status, bytes) {
print("Second write done"); print("Second write done");
assert(status == IOStatus.ok); assert(status == IOStatus.ok);
assert(bytes == pack2.length); assert(bytes == pack2.length);
})(pack2, IOMode.once); })(pack2, IOMode.once);
});
print("Second read"); print("Second read");
incoming.read!((status, bts) { incoming.read!((status, bts) {