From 58b50871a069ac9ff8c58766e58d0652a707af2b Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 28 Jun 2018 19:28:56 +0900 Subject: [PATCH] Add exception handler in stub code Change-Id: I7d04e8583b31cbe2787507b1d33ba724fb628d6b Signed-off-by: Junghoon Park --- idlc/cs_gen/cs_cb_rpc_port.h | 12 +++++++++--- idlc/cs_gen/cs_stub_gen_cb.h | 12 +++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/idlc/cs_gen/cs_cb_rpc_port.h b/idlc/cs_gen/cs_cb_rpc_port.h index a2b52d1..97f6911 100644 --- a/idlc/cs_gen/cs_cb_rpc_port.h +++ b/idlc/cs_gen/cs_cb_rpc_port.h @@ -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) diff --git a/idlc/cs_gen/cs_stub_gen_cb.h b/idlc/cs_gen/cs_stub_gen_cb.h index 7a7a99c..3be382a 100644 --- a/idlc/cs_gen/cs_stub_gen_cb.h +++ b/idlc/cs_gen/cs_stub_gen_cb.h @@ -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"; -- 2.7.4