Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

servers, util: fix deadlock caused by conflicting lock order #3340

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions servers/src/mining/stratumserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,13 @@ impl WorkersList {
}
pub fn remove_worker(&self, worker_id: usize) {
self.update_stats(worker_id, |ws| ws.is_connected = false);
self.workers_list
.write()
let mut stratum_stats = self.stratum_stats.write();
let mut workers_list = self.workers_list.write();
workers_list
.remove(&worker_id)
.expect("Stratum: no such addr in map");
self.stratum_stats.write().num_workers = self.workers_list.read().len();

stratum_stats.num_workers = workers_list.len();
}

pub fn login(&self, worker_id: usize, login: String, agent: String) -> Result<(), RpcError> {
Expand Down
3 changes: 2 additions & 1 deletion util/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub fn init_logger(config: Option<LoggingConfig>, logs_tx: Option<mpsc::SyncSend
*tui_running_ref = true;
}

let mut was_init_ref = WAS_INIT.lock();

// Save current logging configuration
let mut config_ref = LOGGING_CONFIG.lock();
*config_ref = c.clone();
Expand Down Expand Up @@ -250,7 +252,6 @@ pub fn init_logger(config: Option<LoggingConfig>, logs_tx: Option<mpsc::SyncSend
);

// Mark logger as initialized
let mut was_init_ref = WAS_INIT.lock();
*was_init_ref = true;
}

Expand Down