summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsemun-lee <35090067+semun-lee@users.noreply.github.com>2019-09-30 10:58:09 +0900
committerGitHub <noreply@github.com>2019-09-30 10:58:09 +0900
commit37ceeeaae90771e50754c10706eec0355e7aa27e (patch)
tree1728dc93cbd94f77fa373409c6762ab6321b0445
parentd079b363c1d8a28dc0937859e5293c9ceb99a435 (diff)
downloadtizenfx-37ceeeaae90771e50754c10706eec0355e7aa27e.tar.gz
tizenfx-37ceeeaae90771e50754c10706eec0355e7aa27e.tar.bz2
tizenfx-37ceeeaae90771e50754c10706eec0355e7aa27e.zip
[IoTConnectivity] Fix wrong callback management (#1041)
* [IoTConnectivity] Fix wrong callback management Change-Id: I5f9ba403661e32f2f6ed807318cc937b8137cfc9 Signed-off-by: Semun Lee <semun.lee@samsung.com> * Change id to static Change-Id: Ib6dd29d64f0c9b991c0a0bfe28f62d187b0fbd61 Signed-off-by: Semun Lee <semun.lee@samsung.com>
-rwxr-xr-xsrc/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs
index 6a7d1b412..d8101b1ea 100755
--- a/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs
+++ b/src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Concurrent;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
@@ -37,8 +38,8 @@ namespace Tizen.Network.IoTConnectivity
private bool _cacheEnabled = false;
private ResourceOptions _options;
- private int _responseCallbackId = 1;
- private static Dictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback> _responseCallbacksMap = new Dictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback>();
+ private static int _responseCallbackId = 1;
+ private static IDictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback> _responseCallbacksMap = new ConcurrentDictionary<IntPtr, Interop.IoTConnectivity.Client.RemoteResource.ResponseCallback>();
private Interop.IoTConnectivity.Client.RemoteResource.CachedRepresentationChangedCallback _cacheUpdatedCallback;
private Interop.IoTConnectivity.Client.RemoteResource.StateChangedCallback _stateChangedCallback;
@@ -404,10 +405,8 @@ namespace Tizen.Network.IoTConnectivity
_responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
{
IntPtr responseCallbackId = userData;
- lock(_responseCallbacksMap)
- {
- _responseCallbacksMap.Remove(responseCallbackId);
- }
+
+ _responseCallbacksMap.Remove(responseCallbackId);
if (responseHandle != IntPtr.Zero)
{
@@ -459,10 +458,9 @@ namespace Tizen.Network.IoTConnectivity
_responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
{
IntPtr responseCallbackId = userData;
- lock (_responseCallbacksMap)
- {
- _responseCallbacksMap.Remove(responseCallbackId);
- }
+
+ _responseCallbacksMap.Remove(responseCallbackId);
+
if (err == (int)(IoTConnectivityError.Iotivity))
{
RemoteResponse response = new RemoteResponse();
@@ -519,10 +517,9 @@ namespace Tizen.Network.IoTConnectivity
_responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
{
IntPtr responseCallbackId = userData;
- lock (_responseCallbacksMap)
- {
- _responseCallbacksMap.Remove(responseCallbackId);
- }
+
+ _responseCallbacksMap.Remove(responseCallbackId);
+
if (responseHandle != IntPtr.Zero)
{
try
@@ -570,10 +567,9 @@ namespace Tizen.Network.IoTConnectivity
_responseCallbacksMap[id] = (IntPtr resource, int err, int requestType, IntPtr responseHandle, IntPtr userData) =>
{
IntPtr responseCallbackId = userData;
- lock (_responseCallbacksMap)
- {
- _responseCallbacksMap.Remove(responseCallbackId);
- }
+
+ _responseCallbacksMap.Remove(responseCallbackId);
+
if (err == (int)(IoTConnectivityError.Iotivity))
{
RemoteResponse response = new RemoteResponse();