net.server_epoll: Support for setting configuration parameters
authorKim Alvefur <zash@zash.se>
Sun, 04 Sep 2016 17:16:46 +0200
changeset 7660 252823632401
parent 7659 296543556065
child 7661 e14a124c4d73
net.server_epoll: Support for setting configuration parameters
net/server_epoll.lua
--- a/net/server_epoll.lua	Fri Sep 02 23:25:11 2016 +0100
+++ b/net/server_epoll.lua	Sun Sep 04 17:16:46 2016 +0200
@@ -26,7 +26,7 @@
 
 local _ENV = nil;
 
-local cfg = {
+local default_config = { __index = {
 	read_timeout = 900;
 	write_timeout = 7;
 	tcp_backlog = 128;
@@ -35,7 +35,8 @@
 	connect_timeout = 20;
 	handshake_timeout = 60;
 	max_wait = 86400;
-};
+}};
+local cfg = default_config.__index;
 
 local fds = createtable(10, 0); -- FD -> conn
 
@@ -633,6 +634,9 @@
 	setquitting = setquitting;
 	wrapclient = wrapclient;
 	link = link;
+	set_config = function (newconfig)
+		cfg = setmetatable(newconfig, default_config);
+	end;
 
 	-- libevent emulation
 	event = { EV_READ = "r", EV_WRITE = "w", EV_READWRITE = "rw", EV_LEAVE = -1 };