Diff

net/server_select.lua @ 2997:6ccaefea80ec

Merge with tip.
author Tobias Markmann <tm@ayena.de>
date Fri, 12 Mar 2010 18:41:05 +0100
parent 2996:b0515ed4d9d7
parent 2740:2442c54cf9ec
child 2998:36c169ed1576
line wrap: on
line diff
--- a/net/server_select.lua	Fri Mar 12 18:37:51 2010 +0100
+++ b/net/server_select.lua	Fri Mar 12 18:41:05 2010 +0100
@@ -430,12 +430,12 @@
 	end
 	local _readbuffer = function( ) -- this function reads data
 		local buffer, err, part = receive( socket, pattern )	-- receive buffer with "pattern"
-		if not err or (err == "wantread" or err == "timeout") or string_len(part) > 0 then -- received something
+		if not err or (err == "wantread" or err == "timeout") or (part and string_len(part) > 0) then -- received something
 			local buffer = buffer or part or ""
 			local len = string_len( buffer )
 			if len > maxreadlen then
 				disconnect( handler, "receive buffer exceeded" )
-				handler.close( true )
+				handler:close( true )
 				return false
 			end
 			local count = len * STAT_UNIT
@@ -448,7 +448,7 @@
 			out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " read error: ", tostring(err) )
 			fatalerror = true
 			disconnect( handler, err )
-		_ = handler and handler.close( )
+		_ = handler and handler:close( )
 			return false
 		end
 	end
@@ -472,7 +472,7 @@
 			_sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist
 			_ = needtls and handler:starttls(nil, true)
 			_writetimes[ handler ] = nil
-			_ = toclose and handler.close( )
+			_ = toclose and handler:close( )
 			return true
 		elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write
 			buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer
@@ -485,7 +485,7 @@
 			out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " write error: ", tostring(err) )
 			fatalerror = true
 			disconnect( handler, err )
-			_ = handler and handler.close( )
+			_ = handler and handler:close( )
 			return false
 		end
 	end