Comparison

net/server_epoll.lua @ 10082:1df53ef1f60d

net.server_epoll: Return errors from creating sockets Prevents error from attempting to index nil conn on such failure. Silences luacheck warning about the 'err' variable being unused
author Kim Alvefur <zash@zash.se>
date Tue, 23 Jul 2019 18:06:34 +0200
parent 10081:72adf1f39404
child 10088:97da8452c6a6
comparison
equal deleted inserted replaced
10081:72adf1f39404 10082:1df53ef1f60d
692 end 692 end
693 if type(create) ~= "function" then 693 if type(create) ~= "function" then
694 return nil, "invalid socket type"; 694 return nil, "invalid socket type";
695 end 695 end
696 local conn, err = create(); 696 local conn, err = create();
697 if not conn then return conn, err; end
697 local ok, err = conn:settimeout(0); 698 local ok, err = conn:settimeout(0);
698 if not ok then return ok, err; end 699 if not ok then return ok, err; end
699 local ok, err = conn:setpeername(addr, port); 700 local ok, err = conn:setpeername(addr, port);
700 if not ok and err ~= "timeout" then return ok, err; end 701 if not ok and err ~= "timeout" then return ok, err; end
701 local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx) 702 local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx)