Fix for Socket crash issue
authoradhavan.m <adhavan.m@samsung.com>
Mon, 23 Jan 2017 14:24:58 +0000 (19:54 +0530)
committeradhavan.m <adhavan.m@samsung.com>
Mon, 23 Jan 2017 14:35:31 +0000 (20:05 +0530)
Signed-off-by: adhavan.m <adhavan.m@samsung.com>
Change-Id: I47888f1a08f0be6130a4f1ae3a763c62cd5a1e15

packaging/csapi-network-bluetooth.spec
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothServerSocket.cs [changed mode: 0644->0755]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothSocket.cs [changed mode: 0644->0755]
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs

index de935bf..6b07ae2 100644 (file)
@@ -8,7 +8,7 @@
 
 Name:       csapi-network-bluetooth
 Summary:    Tizen Bluetooth API for C#
-Version:    1.0.5
+Version:    1.0.6
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
old mode 100644 (file)
new mode 100755 (executable)
index 0d1615e..b7bed91
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
@@ -26,6 +26,7 @@ namespace Tizen.Network.Bluetooth
     public class BluetoothServerSocket : IDisposable
     {
         private event EventHandler<AcceptStateChangedEventArgs> _acceptStateChanged;
+        private Interop.Bluetooth.SocketConnectionStateChangedCallback _connectionStateChangedCallback;
         internal int socketFd;
         private bool disposed = false;
 
@@ -54,7 +55,7 @@ namespace Tizen.Network.Bluetooth
 
         private void RegisterAcceptStateChangedEvent()
         {
-            Interop.Bluetooth.SocketConnectionStateChangedCallback ConnectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
+            _connectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
             {
                 Log.Info(Globals.LogTag, "AcceptStateChanged cb is called");
                 if (_acceptStateChanged != null)
@@ -67,7 +68,7 @@ namespace Tizen.Network.Bluetooth
             };
             GCHandle handle1 = GCHandle.Alloc(this);
             IntPtr data = (IntPtr) handle1;
-            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(ConnectionStateChangedCallback, data);
+            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionStateChangedCallback, data);
             if (ret != (int)BluetoothError.None)
             {
                 Log.Error(Globals.LogTag, "Failed to set accept state changed callback, Error - " + (BluetoothError)ret);
old mode 100644 (file)
new mode 100755 (executable)
index 4fb8416..c24b0d4
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
@@ -43,6 +43,8 @@ namespace Tizen.Network.Bluetooth
     {
         private event EventHandler<SocketDataReceivedEventArgs> _dataReceived;
         private event EventHandler<SocketConnectionStateChangedEventArgs> _connectionStateChanged;
+        private Interop.Bluetooth.DataReceivedCallback _dataReceivedCallback;
+        private Interop.Bluetooth.SocketConnectionStateChangedCallback _connectionStateChangedCallback;
         private bool disposed = false;
         internal int connectedSocket;
         internal string remoteAddress;
@@ -96,7 +98,7 @@ namespace Tizen.Network.Bluetooth
 
         private void RegisterDataReceivedEvent()
         {
-            Interop.Bluetooth.DataReceivedCallback DataReceivedCallback = (ref SocketDataStruct socketData, IntPtr userData) =>
+            _dataReceivedCallback = (ref SocketDataStruct socketData, IntPtr userData) =>
             {
                 Log.Info(Globals.LogTag, "DataReceivedCallback is called");
                 if (_dataReceived != null)
@@ -107,7 +109,7 @@ namespace Tizen.Network.Bluetooth
             };
             GCHandle handle1 = GCHandle.Alloc (this);
             IntPtr uData = (IntPtr) handle1;
-            int ret = Interop.Bluetooth.SetDataReceivedCallback(DataReceivedCallback, uData);
+            int ret = Interop.Bluetooth.SetDataReceivedCallback(_dataReceivedCallback, uData);
             if (ret != (int)BluetoothError.None)
             {
                 Log.Error(Globals.LogTag, "Failed to set data received callback, Error - " + (BluetoothError)ret);
@@ -127,7 +129,7 @@ namespace Tizen.Network.Bluetooth
 
         private void RegisterConnectionStateChangedEvent()
         {
-            Interop.Bluetooth.SocketConnectionStateChangedCallback ConnectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
+            _connectionStateChangedCallback = (int result, BluetoothSocketState connectionState, ref SocketConnectionStruct socketConnection, IntPtr userData) =>
             {
                 Log.Info(Globals.LogTag, "ConnectionStateChangedCallback is called");
                 if (_connectionStateChanged != null)
@@ -139,7 +141,7 @@ namespace Tizen.Network.Bluetooth
             };
             GCHandle handle1 = GCHandle.Alloc(this);
             IntPtr data = (IntPtr) handle1;
-            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(ConnectionStateChangedCallback, data);
+            int ret = Interop.Bluetooth.SetConnectionStateChangedCallback(_connectionStateChangedCallback, data);
             if (ret != (int)BluetoothError.None)
             {
                 Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (BluetoothError)ret);
index 9a2e87a..476e1d8 100755 (executable)
@@ -154,7 +154,7 @@ namespace Tizen.Network.Bluetooth
     {
         internal int SocketFd;
         internal int DataSize;
-        internal string Data;
+        internal IntPtr Data;
     }
 
     internal struct SocketConnectionStruct
@@ -327,7 +327,7 @@ namespace Tizen.Network.Bluetooth
             SocketData data = new SocketData();
             data.Fd = structInfo.SocketFd;
             data.Size = structInfo.DataSize;
-            data.RecvData = structInfo.Data;
+            data.RecvData = Marshal.PtrToStringAnsi(structInfo.Data);
             return data;
         }