Changeset

7657:252823632401

net.server_epoll: Support for setting configuration parameters
author Kim Alvefur <zash@zash.se>
date Sun, 04 Sep 2016 17:16:46 +0200
parents 7656:296543556065
children 7658:e14a124c4d73
files net/server_epoll.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 };