Add exception handler in stub code 79/182879/2
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 28 Jun 2018 10:28:56 +0000 (19:28 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 28 Jun 2018 10:30:56 +0000 (19:30 +0900)
Change-Id: I7d04e8583b31cbe2787507b1d33ba724fb628d6b
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
idlc/cs_gen/cs_cb_rpc_port.h
idlc/cs_gen/cs_stub_gen_cb.h

index a2b52d11f40c397039a76d8dc9fbe0a50b8ad55d..97f69113086a207f4e642c7e1c51ca969fdf12a3 100644 (file)
@@ -46,17 +46,23 @@ namespace Tizen.Applications.RPCPort
 
         public Parcel()
         {
-            Interop.LibRPCPort.Parcel.Create(out _handle);
+            var r = Interop.LibRPCPort.Parcel.Create(out _handle);
+            if (r != Interop.LibRPCPort.ErrorCode.None)
+                throw new InvalidIOException();
         }
 
         public Parcel(Port port)
         {
-            Interop.LibRPCPort.Parcel.CreateFromPort(out _handle, port.Handle);
+            var r = Interop.LibRPCPort.Parcel.CreateFromPort(out _handle, port.Handle);
+            if (r != Interop.LibRPCPort.ErrorCode.None)
+                throw new InvalidIOException();
         }
 
         public void Send(Port p)
         {
-            Interop.LibRPCPort.Parcel.Send(_handle, p.Handle);
+            var r = Interop.LibRPCPort.Parcel.Send(_handle, p.Handle);
+            if (r != Interop.LibRPCPort.ErrorCode.None)
+                throw new InvalidIOException();
         }
 
         public void WriteByte(byte b)
index 7a7a99c195a9524d6a4f17018f6d86029f73471d..3be382aae0b827397133fc98de077f7fbd990371 100644 (file)
@@ -61,7 +61,9 @@ const char CB_ON_RECEIVED_EVENT_FRONT[] =
 R"__cs_cb(
             protected override bool OnReceivedEvent(string sender, string instance, Port port)
             {
-                using (var p = new Parcel(port))
+                var p = new Parcel(port);
+
+                try
                 {
                     ServiceBase b = null;
 
@@ -96,6 +98,14 @@ R"__cs_cb(
 
                     return true;
                 }
+                catch (InvalidIOException)
+                {
+                    return false;
+                }
+                finally
+                {
+                    p.Dispose();
+                }
             }
 )__cs_cb";