Drop is run only AFTER each statement.

And the guard generated here in the if let Some() will live through the WHOLE statement, which is definitly critical.
The fix is quite easy. We just move it out in a seperate line.
There are still some participants where the dropping will fail, and followup disconnects will NOT get triggered and be queued up till ethernity, but at least we are not blocking new logins
This commit is contained in:
Marcel Märtens 2020-11-25 21:42:33 +01:00
parent 103c2302b0
commit 1b18b43fa7

View File

@ -270,7 +270,9 @@ impl Scheduler {
// 3. Participant will try to access the BParticipant senders and receivers with
// their next api action, it will fail and be closed then.
trace!(?pid, "Got request to close participant");
if let Some(mut pi) = self.participants.lock().await.remove(&pid) {
let pi = self.participants.lock().await.remove(&pid);
trace!(?pid, "dropped participants lock");
if let Some(mut pi) = pi {
let (finished_sender, finished_receiver) = oneshot::channel();
pi.s2b_shutdown_bparticipant_s
.take()
@ -278,8 +280,9 @@ impl Scheduler {
.send(finished_sender)
.unwrap();
drop(pi);
trace!("dropped bparticipant, waiting for finish");
trace!(?pid, "dropped bparticipant, waiting for finish");
let e = finished_receiver.await.unwrap();
trace!(?pid, "waiting completed");
return_once_successful_shutdown.send(e).unwrap();
} else {
debug!(?pid, "Looks like participant is already dropped");