From edb2882b9626094846f546f54b4b48963abcaf1b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 16 Dec 2013 23:24:16 +0000 Subject: net.http: assert() for socket creation success so it doesn't silently fail (thanks daurnimator) --- net/http.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/http.lua b/net/http.lua index b7d2beb9..6ddb1900 100644 --- a/net/http.lua +++ b/net/http.lua @@ -20,6 +20,7 @@ local t_insert, t_concat = table.insert, table.concat; local pairs = pairs; local tonumber, tostring, xpcall, select, traceback = tonumber, tostring, xpcall, select, debug.traceback; +local assert, error = assert, error local log = require "util.logger".init("http"); @@ -173,7 +174,7 @@ function request(u, ex, callback) sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2" } }; end - req.handler, req.conn = server.wrapclient(conn, host, port_number, listener, "*a", sslctx); + req.handler, req.conn = assert(server.wrapclient(conn, host, port_number, listener, "*a", sslctx)); req.write = function (...) return req.handler:write(...); end req.callback = function (content, code, request, response) log("debug", "Calling callback, status %s", code or "---"); return select(2, xpcall(function () return callback(content, code, request, response) end, handleerr)); end -- cgit v1.2.3 From e204ed5dce8050537ca6d8af0c69a8b62ea8aa2e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 16 Dec 2013 23:31:43 +0000 Subject: net.server_select: Don't remove the socket from sendlist when we might have data in the buffer (we'll now let sendbuffer() take care of that) (thanks daurnimator) --- net/server_select.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'net') diff --git a/net/server_select.lua b/net/server_select.lua index d0894715..22887265 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -916,13 +916,9 @@ local wrapclient = function( socket, ip, serverport, listeners, pattern, sslctx -- When socket is writeable, call onconnect local _sendbuffer = handler.sendbuffer; handler.sendbuffer = function () - _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ); handler.sendbuffer = _sendbuffer; listeners.onconnect(handler); - -- If there was data with the incoming packet, handle it now. - if #handler:bufferqueue() > 0 then - return _sendbuffer(); - end + return _sendbuffer(); -- Send any queued outgoing data end end end -- cgit v1.2.3