Software / code / prosody
Comparison
net/server_select.lua @ 6542:32c84e1f706d
net.server_select: Remove socket.sleep call from main loop
It's been there since the start; but should really not be required.
People can remember an issue with FreeBSD that this solved, but this was a hack solution anyway.
If that issue rears it's head again, we will solve it properly.
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Mon, 19 Jan 2015 14:05:37 -0500 |
| parent | 6541:a702786f4f31 |
| child | 6543:01cd51777abb |
comparison
equal
deleted
inserted
replaced
| 6541:a702786f4f31 | 6542:32c84e1f706d |
|---|---|
| 55 | 55 |
| 56 --// extern lib methods //-- | 56 --// extern lib methods //-- |
| 57 | 57 |
| 58 local ssl_wrap = ( has_luasec and luasec.wrap ) | 58 local ssl_wrap = ( has_luasec and luasec.wrap ) |
| 59 local socket_bind = luasocket.bind | 59 local socket_bind = luasocket.bind |
| 60 local socket_sleep = luasocket.sleep | |
| 61 local socket_select = luasocket.select | 60 local socket_select = luasocket.select |
| 62 | 61 |
| 63 --// functions //-- | 62 --// functions //-- |
| 64 | 63 |
| 65 local id | 64 local id |
| 99 | 98 |
| 100 local _sendtraffic | 99 local _sendtraffic |
| 101 local _readtraffic | 100 local _readtraffic |
| 102 | 101 |
| 103 local _selecttimeout | 102 local _selecttimeout |
| 104 local _sleeptime | |
| 105 local _tcpbacklog | 103 local _tcpbacklog |
| 106 | 104 |
| 107 local _starttime | 105 local _starttime |
| 108 local _currenttime | 106 local _currenttime |
| 109 | 107 |
| 136 | 134 |
| 137 _sendtraffic = 0 -- some stats | 135 _sendtraffic = 0 -- some stats |
| 138 _readtraffic = 0 | 136 _readtraffic = 0 |
| 139 | 137 |
| 140 _selecttimeout = 1 -- timeout of socket.select | 138 _selecttimeout = 1 -- timeout of socket.select |
| 141 _sleeptime = 0 -- time to wait at the end of every loop | |
| 142 _tcpbacklog = 128 -- some kind of hint to the OS | 139 _tcpbacklog = 128 -- some kind of hint to the OS |
| 143 | 140 |
| 144 _maxsendlen = 51000 * 1024 -- max len of send buffer | 141 _maxsendlen = 51000 * 1024 -- max len of send buffer |
| 145 _maxreadlen = 25000 * 1024 -- max len of read buffer | 142 _maxreadlen = 25000 * 1024 -- max len of read buffer |
| 146 | 143 |
| 788 end | 785 end |
| 789 | 786 |
| 790 getsettings = function( ) | 787 getsettings = function( ) |
| 791 return { | 788 return { |
| 792 select_timeout = _selecttimeout; | 789 select_timeout = _selecttimeout; |
| 793 select_sleep_time = _sleeptime; | |
| 794 tcp_backlog = _tcpbacklog; | 790 tcp_backlog = _tcpbacklog; |
| 795 max_send_buffer_size = _maxsendlen; | 791 max_send_buffer_size = _maxsendlen; |
| 796 max_receive_buffer_size = _maxreadlen; | 792 max_receive_buffer_size = _maxreadlen; |
| 797 select_idle_check_interval = _checkinterval; | 793 select_idle_check_interval = _checkinterval; |
| 798 send_timeout = _sendtimeout; | 794 send_timeout = _sendtimeout; |
| 806 changesettings = function( new ) | 802 changesettings = function( new ) |
| 807 if type( new ) ~= "table" then | 803 if type( new ) ~= "table" then |
| 808 return nil, "invalid settings table" | 804 return nil, "invalid settings table" |
| 809 end | 805 end |
| 810 _selecttimeout = tonumber( new.select_timeout ) or _selecttimeout | 806 _selecttimeout = tonumber( new.select_timeout ) or _selecttimeout |
| 811 _sleeptime = tonumber( new.select_sleep_time ) or _sleeptime | |
| 812 _maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen | 807 _maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen |
| 813 _maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen | 808 _maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen |
| 814 _checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval | 809 _checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval |
| 815 _tcpbacklog = tonumber( new.tcp_backlog ) or _tcpbacklog | 810 _tcpbacklog = tonumber( new.tcp_backlog ) or _tcpbacklog |
| 816 _sendtimeout = tonumber( new.send_timeout ) or _sendtimeout | 811 _sendtimeout = tonumber( new.send_timeout ) or _sendtimeout |
| 939 _readtimes[ handler ] = _currenttime -- reset timer | 934 _readtimes[ handler ] = _currenttime -- reset timer |
| 940 end | 935 end |
| 941 end | 936 end |
| 942 end | 937 end |
| 943 end | 938 end |
| 944 | |
| 945 -- wait some time (0 by default) | |
| 946 socket_sleep( _sleeptime ) | |
| 947 until quitting; | 939 until quitting; |
| 948 if once and quitting == "once" then quitting = nil; return; end | 940 if once and quitting == "once" then quitting = nil; return; end |
| 949 return "quitting" | 941 return "quitting" |
| 950 end | 942 end |
| 951 | 943 |