From ded51b2b2098fccd010a19205218594d6e277688 Mon Sep 17 00:00:00 2001 From: Bruno-DaSilva Date: Tue, 1 Dec 2020 21:23:41 -0800 Subject: [PATCH] Add unlocks to error cases in handlers::handlePublish() In handlers::handlePublish(), the mutex for the rtmp stream is locked at the beginning of the function. The previous implementation checked for error cases (e.g. incorrect stream key), logging and immediately returning if an error case was found. The mutex, however, was not unlocked, leading to the server effectively 'freezing' as other interactions try and lock that mutex. This MR adds mutex unlocks in each error case to ensure that the server continues to function in the event of a recoverable error. --- handlers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/handlers.go b/handlers.go index 0a2a3a2..e2c30dd 100644 --- a/handlers.go +++ b/handlers.go @@ -363,16 +363,19 @@ func handlePublish(conn *rtmp.Conn) { if len(urlParts) > 2 { common.LogErrorln("Extra garbage after stream key") + l.Unlock() return } if len(urlParts) != 2 { common.LogErrorln("Missing stream key") + l.Unlock() return } if urlParts[1] != settings.GetStreamKey() { common.LogErrorln("Stream key is incorrect. Denying stream.") + l.Unlock() return //If key not match, deny stream }