aws/s3hlssink: Fix deadlock on EOS

In state change to NULL, we take state lock and call stop. When stop
is called, we will try to upload queued segments in S3 request thread.
That tries to take the state lock again and deadlocks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1086>
This commit is contained in:
Sanchayan Maity 2023-02-03 17:00:57 +05:30 committed by Sebastian Dröge
parent 7a8ecb5343
commit 0e55e19d57

View file

@ -408,6 +408,9 @@ impl S3HlsSink {
}
};
};
let mut state = self.state.lock().unwrap();
*state = State::Stopped
}
fn create_stats(&self) -> gst::Structure {
@ -651,6 +654,7 @@ impl ObjectImpl for S3HlsSink {
State::Started(ref mut state) => state.num_uploads_started += 1,
State::Stopped => unreachable!("State not started yet"),
};
drop(state);
let s3_location = args[1].get::<&str>().unwrap();
let upload = S3Upload::new(
@ -685,6 +689,7 @@ impl ObjectImpl for S3HlsSink {
State::Started(ref mut state) => state.num_uploads_started += 1,
State::Stopped => unreachable!("State not started yet"),
};
drop(state);
let s3_location = args[1].get::<&str>().unwrap();
let upload = S3Upload::new(
@ -810,10 +815,12 @@ impl ElementImpl for S3HlsSink {
* in turn will require the settings lock.
*/
let settings = self.settings.lock().unwrap();
let mut state = self.state.lock().unwrap();
match transition {
gst::StateChange::ReadyToPaused => *state = State::Started(Started::default()),
gst::StateChange::ReadyToPaused => {
let mut state = self.state.lock().unwrap();
*state = State::Started(Started::default());
}
gst::StateChange::PausedToPlaying => {
let s3_txc = settings.s3_txc.clone();
if let Some(tx) = s3_txc {
@ -851,8 +858,6 @@ impl ElementImpl for S3HlsSink {
* pending requests.
*/
self.stop();
*state = State::Stopped
}
_ => (),
}