Changeset

5967:3b7206981317

net.server_{select,event}: addclient: Handle missing getaddrinfo
author Kim Alvefur <zash@zash.se>
date Mon, 23 Dec 2013 23:23:59 +0100
parents 5966:958ad646c0f2
children 5973:905b4fd863b4
files net/server_event.lua net/server_select.lua
diffstat 2 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Mon Dec 23 17:57:53 2013 +0100
+++ b/net/server_event.lua	Mon Dec 23 23:23:59 2013 +0100
@@ -742,16 +742,14 @@
 			debug "need luasec, but not available"
 			return nil, "luasec not found"
 		end
-		if not typ then
+		if getaddrinfo and not typ then
 			local addrinfo, err = getaddrinfo(addr)
 			if not addrinfo then return nil, err end
 			if addrinfo[1] and addrinfo[1].family == "inet6" then
 				typ = "tcp6"
-			else
-				typ = "tcp"
 			end
 		end
-		local create = socket[typ]
+		local create = socket[typ or "tcp"]
 		if type( create ) ~= "function"  then
 			return nil, "invalid socket type"
 		end
--- a/net/server_select.lua	Mon Dec 23 17:57:53 2013 +0100
+++ b/net/server_select.lua	Mon Dec 23 23:23:59 2013 +0100
@@ -942,16 +942,14 @@
 	elseif sslctx and not has_luasec then
 		err = "luasec not found"
 	end
-	if not typ then
+	if getaddrinfo and not typ then
 		local addrinfo, err = getaddrinfo(address)
 		if not addrinfo then return nil, err end
 		if addrinfo[1] and addrinfo[1].family == "inet6" then
 			typ = "tcp6"
-		else
-			typ = "tcp"
 		end
 	end
-	local create = luasocket[typ]
+	local create = luasocket[typ or "tcp"]
 	if type( create ) ~= "function"  then
 		err = "invalid socket type"
 	end