From: coderhyme Date: Fri, 29 Sep 2017 05:53:10 +0000 (+0900) Subject: [MediaContent] Fixed possible deadlock issues of async methods. X-Git-Tag: preview1-00273^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F153674%2F1;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [MediaContent] Fixed possible deadlock issues of async methods. It could occur when the continuations run synchronously, because the native implementaion holds mutex when it calls the callback. In such situation if any related async method is called, it is going to be blocked. Thus we need to force the continuations to run asyncronously. Change-Id: I5aa12733cde352de65bc722ecebd8c6b3f92d55e Signed-off-by: coderhyme --- diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaDatabase.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaDatabase.cs index 8474364..72031a5 100644 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaDatabase.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaDatabase.cs @@ -354,7 +354,7 @@ namespace Tizen.Content.MediaContent private async Task ScanFolderAsyncCore(string folderPath, bool recursive, CancellationToken cancellationToken) { - var tcs = new TaskCompletionSource(); + var tcs = new TaskCompletionSource(TaskContinuationOptions.RunContinuationsAsynchronously); using (var cbKeeper = ObjectKeeper.Get(GetScanCompletedCallback(tcs, cancellationToken))) using (RegisterCancellationAction(tcs, folderPath, cancellationToken)) diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs index 7eb2be4..f0a5fb3 100644 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs @@ -602,7 +602,7 @@ namespace Tizen.Content.MediaContent ValidatePaths(paths); var pathArray = paths.ToArray(); - var tcs = new TaskCompletionSource(); + var tcs = new TaskCompletionSource(TaskContinuationOptions.RunContinuationsAsynchronously); Interop.MediaInfo.InsertCompletedCallback callback = (error, _) => { @@ -658,7 +658,7 @@ namespace Tizen.Content.MediaContent ValidatePaths(paths); - var tcs = new TaskCompletionSource(); + var tcs = new TaskCompletionSource(TaskContinuationOptions.RunContinuationsAsynchronously); string[] pathArray = paths.ToArray(); Interop.MediaInfo.InsertBurstShotCompletedCallback callback = (error, _) =>