Changeset

7592:10d2f008321d

net.server_epoll: Additional logging of connects and TLS
author Kim Alvefur <zash@zash.se>
date Thu, 18 Aug 2016 16:33:12 +0200
parents 7591:138f16eb39fb
children 7593:0266434d7df1
files net/server_epoll.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Thu Aug 18 16:28:08 2016 +0200
+++ b/net/server_epoll.lua	Thu Aug 18 16:33:12 2016 +0200
@@ -337,7 +337,7 @@
 		log("debug", "Close %s after writing", tostring(self));
 		self._toclose = true;
 	else
-		log("debug", "Close %s", tostring(self));
+		log("debug", "Close %s now", tostring(self));
 		self.close = noop;
 		self:on("disconnect");
 		self:destroy();
@@ -359,8 +359,10 @@
 function interface:starttls(ctx)
 	if ctx then self.tls = ctx; end
 	if self.writebuffer and self.writebuffer[1] then
+		log("debug", "Start TLS on %s after write", tostring(self));
 		self._starttls = true;
 	else
+		log("debug", "Start TLS on %s now", tostring(self));
 		self:setflags(false, false);
 		local conn, err = luasec.wrap(self.conn, ctx or self.tls);
 		if not conn then
@@ -379,6 +381,7 @@
 function interface:tlshandskake()
 	local ok, err = self.conn:dohandshake();
 	if ok then
+		log("debug", "TLS handshake on %s complete", tostring(self));
 		self.onwriteable = nil;
 		self.onreadable = nil;
 		self:setflags(true, true);
@@ -391,14 +394,17 @@
 			self:on("status", "ssl-handshake-complete");
 		end
 	elseif err == "wantread" then
+		log("debug", "TLS handshake on %s to wait until readable", tostring(self));
 		self:setflags(true, false);
 		self:setwritetimeout(false);
 		self:setreadtimeout(cfg.handshake_timeout);
 	elseif err == "wantwrite" then
+		log("debug", "TLS handshake on %s to wait until writable", tostring(self));
 		self:setflags(false, true);
 		self:setreadtimeout(false);
 		self:setwritetimeout(cfg.handshake_timeout);
 	else
+		log("debug", "TLS handshake error on %s: %s", tostring(self), err);
 		self:on("disconnect", err);
 		self:destroy();
 	end
@@ -436,6 +442,7 @@
 		return;
 	end
 	local client = wrapsocket(conn, self, nil, self.listeners, self.tls);
+	log("debug", "New connection %s", tostring(client));
 	if self.tls then
 		client._tls = false;
 		client:starttls();