Skip to content

Commit f829d04

Browse files
committed
remove group channel deadlock in close channel flow
1 parent 624936b commit f829d04

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

miner-apps/translator/src/lib/sv2/channel_manager/mining_message_handler.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,13 @@ impl HandleMiningMessagesFromServerAsync for ChannelManager {
310310
return Err(TproxyError::fallback(
311311
TproxyErrorKind::AggregatedChannelClosed,
312312
));
313+
}
314+
315+
let group_channel = self.group_channels.remove(&m.channel_id);
316+
313317
// we're not in aggregated mode
314318
// was the message sent to a group channel?
315-
} else if let Some(group_channel_arc) = self.group_channels.get(&m.channel_id) {
319+
if let Some((_, group_channel_arc)) = group_channel {
316320
let group_channel = group_channel_arc.read().map_err(|e| {
317321
error!("Failed to read group channel: {:?}", e);
318322
TproxyError::shutdown(TproxyErrorKind::PoisonLock)
@@ -321,9 +325,6 @@ impl HandleMiningMessagesFromServerAsync for ChannelManager {
321325
for channel_id in group_channel.get_channel_ids() {
322326
self.extended_channels.remove(channel_id);
323327
}
324-
325-
drop(group_channel);
326-
self.group_channels.remove(&m.channel_id);
327328
// if the message was not sent to a group channel, and we're not working in
328329
// aggregated mode,
329330
} else if self.extended_channels.contains_key(&m.channel_id) {
@@ -347,6 +348,7 @@ impl HandleMiningMessagesFromServerAsync for ChannelManager {
347348
);
348349
return Err(TproxyError::log(TproxyErrorKind::ChannelNotFound));
349350
}
351+
350352
Ok(())
351353
}
352354

0 commit comments

Comments
 (0)