From ac811ba5019e0deb2faad035f96aaccb2093757c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 30 Jan 2017 11:40:11 +0100 Subject: [PATCH] Remove buggy NetworkAddress.toUnknownAddress. UnknownAddress is not large enough to hold either IPv6 or UDS addresses. --- source/vibe/core/net.d | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/source/vibe/core/net.d b/source/vibe/core/net.d index 7a5811f..b0a158d 100644 --- a/source/vibe/core/net.d +++ b/source/vibe/core/net.d @@ -102,7 +102,8 @@ TCPListener listenTCP(ushort port, TCPConnectionDelegate connection_callback, st StreamListenOptions sopts = StreamListenOptions.defaults; if (options & TCPListenOptions.reusePort) sopts |= StreamListenOptions.reusePort; - auto sock = eventDriver.sockets.listenStream(addr.toUnknownAddress, sopts, + scope addrc = new RefAddress(addr.sockAddr, addr.sockAddrLen); + auto sock = eventDriver.sockets.listenStream(addrc, sopts, (StreamListenSocketFD ls, StreamSocketFD s, scope RefAddress addr) @safe nothrow { import vibe.core.core : runTask; auto conn = TCPConnection(s, addr); @@ -386,18 +387,6 @@ struct NetworkAddress { } } - UnknownAddress toUnknownAddress() - const nothrow { - auto ret = new UnknownAddress; - toUnknownAddress(ret); - return ret; - } - - void toUnknownAddress(scope UnknownAddress addr) - const nothrow { - *addr.name = *this.sockAddr; - } - version(Have_libev) {} else { unittest { @@ -699,7 +688,8 @@ struct UDPConnection { private this(ref NetworkAddress bind_address) { - m_socket = eventDriver.sockets.createDatagramSocket(bind_address.toUnknownAddress(), null); + scope baddr = new RefAddress(bind_address.sockAddr, bind_address.sockAddrLen); + m_socket = eventDriver.sockets.createDatagramSocket(baddr, null); enforce(m_socket != DatagramSocketFD.invalid, "Failed to create datagram socket."); m_context = () @trusted { return &eventDriver.core.userData!Context(m_socket); } (); m_context.localAddress = bind_address;