Commit 149b0587a0

149b0587a05b3dd57a71b3416be929a6b057a34d

parent: 5c1cf0dafd

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2019-12-22 21:09 UTC

config: Don't keep the borrow of the servers in the read cb.

Layout: unified · split

src/config.rs +17 −12
@@ -70,18 +70,23 @@ impl Config {
70 let server_name = option_args[0]; 70 let server_name = option_args[0];
71 let option_name = option_args[1]; 71 let option_name = option_args[1];
72 72
73 let servers = servers.upgrade(); 73 {
74 74 let servers = servers.upgrade();
75 let mut servers_borrow = servers.borrow_mut(); 75 let mut servers_borrow = servers.borrow_mut();
76 76
77 // We are reading the config, if the server doesn't yet exists 77 // We are reading the config, if the server doesn't yet exists
78 // we need to create it before setting the option and running 78 // we need to create it before setting the option and running
79 // the option change callback. 79 // the option change callback.
80 if !servers_borrow.contains_key(server_name) { 80 if !servers_borrow.contains_key(server_name) {
81 let config = Config(config.upgrade().unwrap()); 81 let config = config.upgrade();
82 let server = 82 let server = MatrixServer::new(
83 MatrixServer::new(server_name, &config, section); 83 server_name,
84 servers_borrow.insert(server_name.to_owned(), server); 84 &config,
85 section,
86 );
87 servers_borrow
88 .insert(server_name.to_owned(), server);
89 }
85 } 90 }
86 91
87 let option = section.search_option(option_name); 92 let option = section.search_option(option_name);