Commit a95880aa86

a95880aa86d5601398a1b4078d1b143d1cd13541

parent: 426b9c64cc

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-01-12 11:02 UTC

lib: Don't read the config in an async task.

Layout: unified · split

src/lib.rs +12 −8
@@ -95,18 +95,22 @@ impl WeechatPlugin for Matrix {
95 config: config.clone(), 95 config: config.clone(),
96 }; 96 };
97 97
98 spawn_weechat(async move { 98 {
99 { 99 let config_borrow = config.borrow();
100 let config = config.borrow(); 100 if config_borrow.read().is_err() {
101 config.read().expect("Can't read config"); 101 return Err(weechat::Error(-1));
102 } 102 }
103 }
103 104
104 let mut servers = servers.borrow_mut(); 105 {
105 106 let mut servers_borrow = servers.borrow_mut();
106 if servers.is_empty() { 107 if servers_borrow.is_empty() {
107 Matrix::create_default_server(&mut servers, &config) 108 Matrix::create_default_server(&mut servers_borrow, &config)
108 } 109 }
110 }
109 111
112 spawn_weechat(async move {
113 let mut servers = servers.borrow_mut();
110 Matrix::autoconnect(&mut servers); 114 Matrix::autoconnect(&mut servers);
111 }); 115 });
112 116