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 {
7070 let server_name = option_args[0];
7171 let option_name = option_args[1];
7272
73 let servers = servers.upgrade();
74
75 let mut servers_borrow = servers.borrow_mut();
76
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
79 // the option change callback.
80 if !servers_borrow.contains_key(server_name) {
81 let config = Config(config.upgrade().unwrap());
82 let server =
83 MatrixServer::new(server_name, &config, section);
84 servers_borrow.insert(server_name.to_owned(), server);
73 {
74 let servers = servers.upgrade();
75 let mut servers_borrow = servers.borrow_mut();
76
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
79 // the option change callback.
80 if !servers_borrow.contains_key(server_name) {
81 let config = config.upgrade();
82 let server = MatrixServer::new(
83 server_name,
84 &config,
85 section,
86 );
87 servers_borrow
88 .insert(server_name.to_owned(), server);
89 }
8590 }
8691
8792 let option = section.search_option(option_name);