Comparison

net/server.lua @ 7543:23a8a26e8912

net.server: Fix whitespace
author Kim Alvefur <zash@zash.se>
date Wed, 10 Aug 2016 16:44:59 +0200
parent 7099:8e64e7b82928
child 7544:fb68aad9dc4d
comparison
equal deleted inserted replaced
7542:0f92dc8e8b88 7543:23a8a26e8912
26 local defaults = {}; 26 local defaults = {};
27 for k,v in pairs(server.cfg) do 27 for k,v in pairs(server.cfg) do
28 defaults[k] = v; 28 defaults[k] = v;
29 end 29 end
30 function set_config(settings) 30 function set_config(settings)
31 local event_settings = { 31 local event_settings = {
32 ACCEPT_DELAY = settings.accept_retry_interval; 32 ACCEPT_DELAY = settings.accept_retry_interval;
33 ACCEPT_QUEUE = settings.tcp_backlog; 33 ACCEPT_QUEUE = settings.tcp_backlog;
34 CLEAR_DELAY = settings.event_clear_interval; 34 CLEAR_DELAY = settings.event_clear_interval;
35 CONNECT_TIMEOUT = settings.connect_timeout; 35 CONNECT_TIMEOUT = settings.connect_timeout;
36 DEBUG = settings.debug; 36 DEBUG = settings.debug;
37 HANDSHAKE_TIMEOUT = settings.ssl_handshake_timeout; 37 HANDSHAKE_TIMEOUT = settings.ssl_handshake_timeout;
38 MAX_CONNECTIONS = settings.max_connections; 38 MAX_CONNECTIONS = settings.max_connections;
39 MAX_HANDSHAKE_ATTEMPTS = settings.max_ssl_handshake_roundtrips; 39 MAX_HANDSHAKE_ATTEMPTS = settings.max_ssl_handshake_roundtrips;
40 MAX_READ_LENGTH = settings.max_receive_buffer_size; 40 MAX_READ_LENGTH = settings.max_receive_buffer_size;
41 MAX_SEND_LENGTH = settings.max_send_buffer_size; 41 MAX_SEND_LENGTH = settings.max_send_buffer_size;
42 READ_TIMEOUT = settings.read_timeout; 42 READ_TIMEOUT = settings.read_timeout;
43 WRITE_TIMEOUT = settings.send_timeout; 43 WRITE_TIMEOUT = settings.send_timeout;
44 }; 44 };
45 45
46 for k,default in pairs(defaults) do 46 for k,default in pairs(defaults) do
47 server.cfg[k] = event_settings[k] or default; 47 server.cfg[k] = event_settings[k] or default;
48 end 48 end
49 end 49 end
50 elseif server_type == "select" then 50 elseif server_type == "select" then
51 server = require "net.server_select"; 51 server = require "net.server_select";
52 52
53 local defaults = {}; 53 local defaults = {};
54 for k,v in pairs(server.getsettings()) do 54 for k,v in pairs(server.getsettings()) do
55 defaults[k] = v; 55 defaults[k] = v;
56 end 56 end
57 function set_config(settings) 57 function set_config(settings)
58 local select_settings = {}; 58 local select_settings = {};
59 for k,default in pairs(defaults) do 59 for k,default in pairs(defaults) do
60 select_settings[k] = settings[k] or default; 60 select_settings[k] = settings[k] or default;
61 end
62 server.changesettings(select_settings);
63 end 61 end
62 server.changesettings(select_settings);
63 end
64 else 64 else
65 error("Unsupported server type") 65 error("Unsupported server type")
66 end 66 end
67 67
68 -- If server.hook_signal exists, replace signal.signal() 68 -- If server.hook_signal exists, replace signal.signal()