Comparison

net/server.lua @ 5385:d663483036db

net.server, _select: Reorganise configuration of server_select to be more like server_event
author Kim Alvefur <zash@zash.se>
date Sat, 23 Mar 2013 20:06:02 +0100
parent 5383:143670deee3e
child 5531:483f795f6f99
comparison
equal deleted inserted replaced
5384:24f4aed5824f 5385:d663483036db
40 server = require "net.server_select"; 40 server = require "net.server_select";
41 end 41 end
42 42
43 if prosody then 43 if prosody then
44 local config_get = require "core.configmanager".get; 44 local config_get = require "core.configmanager".get;
45 local defaults = {};
46 for k,v in pairs(server.cfg or server.getsettings()) do
47 defaults[k] = v;
48 end
45 local function load_config() 49 local function load_config()
46 local settings = config_get("*", "network_settings") or {}; 50 local settings = config_get("*", "network_settings") or {};
47 if use_luaevent then 51 if use_luaevent then
48 local event_settings = { 52 local event_settings = {
49 ACCEPT_DELAY = settings.event_accept_retry_interval; 53 ACCEPT_DELAY = settings.event_accept_retry_interval;
57 MAX_SEND_LENGTH = settings.max_send_buffer_size; 61 MAX_SEND_LENGTH = settings.max_send_buffer_size;
58 READ_TIMEOUT = settings.read_timeout; 62 READ_TIMEOUT = settings.read_timeout;
59 WRITE_TIMEOUT = settings.send_timeout; 63 WRITE_TIMEOUT = settings.send_timeout;
60 }; 64 };
61 65
62 for k, v in pairs(event_settings) do 66 for k,default in pairs(defaults) do
63 server.cfg[k] = v; 67 server.cfg[k] = event_settings[k] or default;
64 end 68 end
65 else 69 else
66 server.changesettings(settings); 70 local select_settings = {};
71 for k,default in pairs(defaults) do
72 select_settings[k] = settings[k] or default;
73 end
74 server.changesettings(select_settings);
67 end 75 end
68 end 76 end
69 load_config(); 77 load_config();
70 prosody.events.add_handler("config-reloaded", load_config); 78 prosody.events.add_handler("config-reloaded", load_config);
71 end 79 end