Changeset

9310:2d2d4c293efa

net.server_epoll: Rename pattern to read_size
author Kim Alvefur <zash@zash.se>
date Thu, 13 Sep 2018 21:07:44 +0200
parents 9309:33d500c25d76
children 9311:9b0604fe01f1
files net/server_epoll.lua
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Thu Sep 13 20:37:43 2018 +0200
+++ b/net/server_epoll.lua	Thu Sep 13 21:07:44 2018 +0200
@@ -203,7 +203,7 @@
 end
 
 function interface:set_mode(new_mode)
-	self._pattern = new_mode;
+	self.read_size = new_mode;
 end
 
 function interface:setoption(k, v)
@@ -306,7 +306,7 @@
 
 -- Called when socket is readable
 function interface:onreadable()
-	local data, err, partial = self.conn:receive(self._pattern);
+	local data, err, partial = self.conn:receive(self.read_size);
 	if data then
 		self:onconnect();
 		self:on("incoming", data);
@@ -470,14 +470,14 @@
 	end
 end
 
-local function wrapsocket(client, server, pattern, listeners, tls_ctx) -- luasocket object -> interface object
+local function wrapsocket(client, server, read_size, listeners, tls_ctx) -- luasocket object -> interface object
 	client:settimeout(0);
 	local conn = setmetatable({
 		conn = client;
 		_server = server;
 		created = gettime();
 		listeners = listeners;
-		_pattern = pattern or (server and server._pattern);
+		read_size = read_size or (server and server.read_size);
 		writebuffer = {};
 		tls_ctx = tls_ctx;
 	}, interface_mt);
@@ -548,7 +548,7 @@
 	self:on("connect");
 end
 
-local function addserver(addr, port, listeners, pattern, tls_ctx)
+local function addserver(addr, port, listeners, read_size, tls_ctx)
 	local conn, err = socket.bind(addr, port, cfg.tcp_backlog);
 	if not conn then return conn, err; end
 	conn:settimeout(0);
@@ -556,7 +556,7 @@
 		conn = conn;
 		created = gettime();
 		listeners = listeners;
-		_pattern = pattern;
+		read_size = read_size;
 		onreadable = interface.onacceptable;
 		tls_ctx = tls_ctx;
 		tls_direct = tls_ctx and true or false;
@@ -568,8 +568,8 @@
 end
 
 -- COMPAT
-local function wrapclient(conn, addr, port, listeners, pattern, tls_ctx)
-	local client = wrapsocket(conn, nil, pattern, listeners, tls_ctx);
+local function wrapclient(conn, addr, port, listeners, read_size, tls_ctx)
+	local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx);
 	if not client.peername then
 		client.peername, client.peerport = addr, port;
 	end
@@ -582,12 +582,12 @@
 end
 
 -- New outgoing TCP connection
-local function addclient(addr, port, listeners, pattern, tls_ctx)
+local function addclient(addr, port, listeners, read_size, tls_ctx)
 	local conn, err = socket.tcp();
 	if not conn then return conn, err; end
 	conn:settimeout(0);
 	conn:connect(addr, port);
-	local client = wrapsocket(conn, nil, pattern, listeners, tls_ctx)
+	local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx)
 	if tls_ctx then
 		client:starttls(tls_ctx);
 	else