Merge remote-tracking branch 'github/API4' into tizen_4.0
authorDotnetBuild <dotnetbuild.tizen@gmail.com>
Mon, 12 Feb 2018 06:44:22 +0000 (15:44 +0900)
committerDotnetBuild <dotnetbuild.tizen@gmail.com>
Mon, 12 Feb 2018 06:44:22 +0000 (15:44 +0900)
1  2 
src/Tizen.Messaging.Push/Tizen.Messaging.Push/PushImpl.cs

@@@ -166,23 -169,32 +169,37 @@@ namespace Tizen.Messaging.Pus
              registerResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
              {
                  Log.Info(Interop.PushClient.LogTag, "Register Callback Called with " + regResult);
-                 string msg = "";
-                 if (msgPtr != IntPtr.Zero)
+                 if (regResult < Interop.PushClient.Result.Success || regResult > Interop.PushClient.Result.SystemError)
+                 {
+                     Log.Error(Interop.PushClient.LogTag, "registerResult is called but has wrong resResult value");
+                     task.SetException(PushExceptionFactory.CreateResponseException(Interop.PushClient.ServiceError.OpearationFailed));
+                               }
+                 else
                  {
-                     msg = Marshal.PtrToStringAnsi(msgPtr);
+                     string msg = "";
+                     if (msgPtr != IntPtr.Zero)
+                     {
+                         msg = Marshal.PtrToStringAnsi(msgPtr);
+                     }
+                     ServerResponse response = new ServerResponse();
+                     response.ServerResult = (ServerResponse.Result)regResult;
+                     response.ServerMessage = msg;
+                     if (task.TrySetResult(response) == false)
+                     {
+                         Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for register");
+                     }
                  }
-                 ServerResponse response = new ServerResponse();
-                 response.ServerResult = (ServerResponse.Result)regResult;
-                 response.ServerMessage = msg;
-                 if (task.TrySetResult(response) == false)
+                 lock (_lock)
                  {
-                     Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for register");
+                     Log.Error(Interop.PushClient.LogTag, "resigterResult is unset");
+                     registerResult = null;
                  }
 +                lock (_lock)
 +                {
 +                    Log.Error(Interop.PushClient.LogTag, "resigterResult is unset");
 +                    registerResult = null;
 +                }
              };
              Interop.PushClient.ServiceError result = Interop.PushClient.ServiceRegister(_connection, registerResult, IntPtr.Zero);
              Log.Info(Interop.PushClient.LogTag, "Interop.PushClient.ServiceRegister Completed");