net.server_select: Don't limit max file descriptor number on Windows.
authorWaqas Hussain <waqas20@gmail.com>
Mon, 29 Apr 2013 20:26:48 +0500
changeset 5548 c5d1c35c93f4
parent 5547 f306daf2bf6d
child 5549 cce17bcb7c94
net.server_select: Don't limit max file descriptor number on Windows.
net/server_select.lua
--- a/net/server_select.lua	Mon Apr 29 14:01:19 2013 +0200
+++ b/net/server_select.lua	Mon Apr 29 20:26:48 2013 +0500
@@ -149,7 +149,8 @@
 _sendtimeout = 60000 -- allowed send idle time in secs
 _readtimeout = 6 * 60 * 60 -- allowed read idle time in secs
 
-_maxfd = luasocket._SETSIZE or 1024 -- We should ignore this on Windows.  Perhaps by simply setting it to math.huge or something.
+local is_windows = package.config:sub(1,1) == "\\" -- check the directory separator, to detemine whether this is Windows
+_maxfd = luasocket._SETSIZE or (is_windows and math.huge) or 1024 -- max fd number, limit to 1024 by default to prevent glibc buffer overflow, but not on Windows
 _maxselectlen = luasocket._SETSIZE or 1024 -- But this still applies on Windows
 
 _maxsslhandshake = 30 -- max handshake round-trips