From c7090e85ce51443aa322ecd357a7d5b6d9478d30 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 29 Jun 2018 08:13:24 +0900 Subject: [PATCH 01/16] Modify exception handling If Send() method returns EILLEGALACCESS, OnRejected() function is invoked. Change-Id: I83c95f248784b9de1514dab5787fd70221c26dab Signed-off-by: Hwankyu Jhun --- src/fdbroker-internal.cc | 5 ++++- src/proxy-internal.cc | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/fdbroker-internal.cc b/src/fdbroker-internal.cc index d0b53ee..2c183a3 100644 --- a/src/fdbroker-internal.cc +++ b/src/fdbroker-internal.cc @@ -33,6 +33,7 @@ #define LOG_TAG "RPC_PORT" +#define EILLEGALACCESS 127 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus" #define DBUS_PATH_DBUS "/org/freedesktop/DBus" @@ -100,6 +101,8 @@ FdBroker::DBusMock& FdBroker::DBusMock::GetInst() { int FdBroker::DBusMock::Send(const std::string& sender, const std::string& port, int fds[2]) { + if (port == "wrong_port") + return -EILLEGALACCESS; if (ports_.find(port) == ports_.end()) return -1; @@ -295,7 +298,7 @@ int FdBroker::Send(const std::string& target_appid, LOGE("Access Denied[sender_appid : %s]", sender_appid); g_object_unref(msg); g_object_unref(reply); - return -1; + return -EILLEGALACCESS; } LOGD("[Reply : %d]", ret); diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 2b6c6c6..4830f42 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -102,10 +102,13 @@ void Proxy::OnPortAppeared(const std::string& appid, int fds[2] = { 0, }; int r = fd_broker_.Send(appid, port_name, &fds); - if (r <= 0 || fds[0] <= 0 || fds[1] <= 0) { + if (r <= 0) { IEventListener* listener = listener_; listener_ = nullptr; - listener->OnRejected(appid); + if (r == -EILLEGALACCESS) + listener->OnRejected(appid); + else + listener->OnDisconnected(appid); return; } @@ -117,7 +120,8 @@ void Proxy::OnPortAppeared(const std::string& appid, void Proxy::OnPortVanished(const std::string& appid, const std::string& port_name) { - LOGD("endpoint(%s), port_name(%s)", appid.c_str(), port_name.c_str()); + LOGW("[__OnPortVanished__] endpoint(%s), port_name(%s)", + appid.c_str(), port_name.c_str()); } int Proxy::Connect(const std::string appid, const std::string& port_name, -- 2.7.4 From d132e6d984c54f32b2335a2a4f4c350972b02fc9 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 29 Jun 2018 09:51:58 +0900 Subject: [PATCH 02/16] Release version 1.2.1 Changes: - Sleep and retry to write - Modify exception handling Change-Id: I3b5d1799233f946724bea0e20f52358075c3b86c Signed-off-by: Junghoon Park --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index bf63f1d..5c1c181 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.2.0 +Version: 1.2.1 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 6a7164301621049ba29124ed604afb9badff5665 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 2 Aug 2018 08:59:12 +0900 Subject: [PATCH 03/16] Adjust timeout interval The maximum interval is changed to 10 seconds. If the waiting time is more than 10 seconds, the function returns a negative error value. Change-Id: I97c84b6c716c7e7a21910a3619bc879cc9fd1c05 Signed-off-by: Hwankyu Jhun --- src/port-internal.cc | 63 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/port-internal.cc b/src/port-internal.cc index 4287675..42b745c 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -35,10 +35,10 @@ #define LOG_TAG "RPC_PORT" -#define MAX_RETRY_CNT 100 -#define SEND_TIMEOUT 500 -#define MAX_SLEEP 100 * 1000 * 1000 -#define MIN_SLEEP 5 * 1000 * 1000 +#define MAX_CNT 100 +#define MAX_SLEEP 100 +#define MIN_SLEEP 5 +#define BASE_SLEEP 1000 * 1000 namespace rpc_port { namespace internal { @@ -62,13 +62,13 @@ Port::~Port() { int Port::Read(void* buf, unsigned int size) { unsigned int left = size; ssize_t nb; - int retry_cnt = 0; - struct timespec TRY_SLEEP_TIME = { 0, MIN_SLEEP }; + struct timespec TRY_SLEEP_TIME = { 0, MIN_SLEEP * BASE_SLEEP}; int bytes_read = 0; char* buffer = static_cast(buf); + int max_timeout = MAX_CNT * MAX_SLEEP; /* 10 sec */ std::lock_guard lock(mutex_); - while (left && (retry_cnt < MAX_RETRY_CNT)) { + while (left) { nb = read(fd_, buffer, left); if (nb == 0) { LOGE("read_socket: ...read EOF, socket closed %d: nb %d\n", fd_, nb); @@ -76,11 +76,15 @@ int Port::Read(void* buf, unsigned int size) { } else if (nb == -1) { if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { LOGE("read_socket: %d errno, sleep and retry ...", errno); - retry_cnt++; nanosleep(&TRY_SLEEP_TIME, 0); + max_timeout -= (TRY_SLEEP_TIME.tv_nsec / (BASE_SLEEP)); + if (max_timeout <= 0) { + LOGE("read_socket: ...timed out fd %d: errno %d", fd_, errno); + return RPC_PORT_ERROR_IO_ERROR; + } TRY_SLEEP_TIME.tv_nsec *= 2; - if (TRY_SLEEP_TIME.tv_nsec > MAX_SLEEP) - TRY_SLEEP_TIME.tv_nsec = MAX_SLEEP; + if (TRY_SLEEP_TIME.tv_nsec > (MAX_SLEEP * BASE_SLEEP)) + TRY_SLEEP_TIME.tv_nsec = MAX_SLEEP * BASE_SLEEP; continue; } @@ -91,12 +95,11 @@ int Port::Read(void* buf, unsigned int size) { left -= nb; buffer += nb; bytes_read += nb; - retry_cnt = 0; - TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP; + TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP * BASE_SLEEP; } if (left != 0) { - LOGE("error fd %d: retry_cnt %d", fd_, retry_cnt); + LOGE("error fd %d: max_timeout %d", fd_, max_timeout); return RPC_PORT_ERROR_IO_ERROR; } @@ -106,34 +109,49 @@ int Port::Read(void* buf, unsigned int size) { int Port::Write(const void* buf, unsigned int size) { unsigned int left = size; ssize_t nb; - int retry_cnt = 0; - struct timespec TRY_SLEEP_TIME = { 0, MIN_SLEEP }; + struct timespec TRY_SLEEP_TIME = { 0, MIN_SLEEP * BASE_SLEEP }; struct pollfd fds[1]; int ret; int bytes_write = 0; const char* buffer = static_cast(buf); + int max_timeout = MAX_CNT * MAX_SLEEP; /* 10 sec */ + struct timespec start_time = { 0, }; + struct timespec end_time = { 0, }; std::lock_guard lock(mutex_); fds[0].fd = fd_; fds[0].events = POLLOUT; fds[0].revents = 0; - ret = poll(fds, 1, SEND_TIMEOUT); + clock_gettime(CLOCK_MONOTONIC, &start_time); + ret = poll(fds, 1, MAX_SLEEP * 1000); + clock_gettime(CLOCK_MONOTONIC, &end_time); if (ret == 0) { LOGE("write_socket: : fd %d poll timeout", fd_); return RPC_PORT_ERROR_IO_ERROR; } - while (left && (retry_cnt < MAX_RETRY_CNT)) { + max_timeout -= (((end_time.tv_sec - start_time.tv_sec) * 1000) + + ((end_time.tv_nsec - start_time.tv_nsec) / (BASE_SLEEP))); + if (max_timeout <= 0) { + LOGE("write_socket: ...timed out fd %d: errno %d", fd_, errno); + return RPC_PORT_ERROR_IO_ERROR; + } + + while (left) { nb = write(fd_, buffer, left); if (nb == -1) { if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { LOGE("write_socket: %d errno, sleep and retry ...", errno); - retry_cnt++; nanosleep(&TRY_SLEEP_TIME, 0); + max_timeout -= (TRY_SLEEP_TIME.tv_nsec / (BASE_SLEEP)); + if (max_timeout <= 0) { + LOGE("write_socket: ...timed out fd %d: errno %d", fd_, errno); + return RPC_PORT_ERROR_IO_ERROR; + } TRY_SLEEP_TIME.tv_nsec *= 2; - if (TRY_SLEEP_TIME.tv_nsec > MAX_SLEEP) - TRY_SLEEP_TIME.tv_nsec = MAX_SLEEP; + if (TRY_SLEEP_TIME.tv_nsec > (MAX_SLEEP * BASE_SLEEP)) + TRY_SLEEP_TIME.tv_nsec = MAX_SLEEP * BASE_SLEEP; continue; } @@ -144,12 +162,11 @@ int Port::Write(const void* buf, unsigned int size) { left -= nb; buffer += nb; bytes_write += nb; - retry_cnt = 0; - TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP; + TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP * BASE_SLEEP; } if (left != 0) { - LOGE("error fd %d: retry_cnt %d", fd_, retry_cnt); + LOGE("error fd %d: max_timeout %d", fd_, max_timeout); return RPC_PORT_ERROR_IO_ERROR; } -- 2.7.4 From 0543c071d50ec6d20426d1208804eebec9b1288a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 3 Aug 2018 12:15:37 +0900 Subject: [PATCH 04/16] Release version 1.2.2 Changes: - Adjust timeout interval Change-Id: Iedc38f1e0d6eee02d6aeded8b887389ccb713f5b Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index 5c1c181..87a99e4 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.2.1 +Version: 1.2.2 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 796600d5198bb4f9d3ad106456dd28df09ba3698 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 13 Aug 2018 10:46:50 +0900 Subject: [PATCH 05/16] Remove unreachable code Change-Id: I094b5d37556b3157f40b9416c9de1c93c8ce01da Signed-off-by: Hwankyu Jhun --- src/port-internal.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/port-internal.cc b/src/port-internal.cc index 42b745c..7733afd 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -98,11 +98,6 @@ int Port::Read(void* buf, unsigned int size) { TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP * BASE_SLEEP; } - if (left != 0) { - LOGE("error fd %d: max_timeout %d", fd_, max_timeout); - return RPC_PORT_ERROR_IO_ERROR; - } - return RPC_PORT_ERROR_NONE; } @@ -165,11 +160,6 @@ int Port::Write(const void* buf, unsigned int size) { TRY_SLEEP_TIME.tv_nsec = MIN_SLEEP * BASE_SLEEP; } - if (left != 0) { - LOGE("error fd %d: max_timeout %d", fd_, max_timeout); - return RPC_PORT_ERROR_IO_ERROR; - } - return RPC_PORT_ERROR_NONE; } -- 2.7.4 From e2c948ae0e776f112004a3346f07b343cb80e154 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 18 Jul 2018 09:22:55 +0900 Subject: [PATCH 06/16] Modified the description - Changes since_tizen tags Change-Id: Ie52906f901b289273d4dcc0bcb8658f98efec2f1 Signed-off-by: Hwankyu Jhun --- include/rpc-port-parcel.h | 60 ++++++++++++++++++++++----------------------- include/rpc-port.h | 62 +++++++++++++++++++++++------------------------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/include/rpc-port-parcel.h b/include/rpc-port-parcel.h index 4ba9f9f..1a3d661 100644 --- a/include/rpc-port-parcel.h +++ b/include/rpc-port-parcel.h @@ -32,13 +32,13 @@ extern "C" { /** * @brief The rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef void *rpc_port_parcel_h; /** * @brief The interface for converting data to/from a parcel. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef struct __rpc_port_parcelable { void (*to)(rpc_port_parcel_h h, void *data); @@ -47,7 +47,7 @@ typedef struct __rpc_port_parcelable { /** * @brief Creates a rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks You must release @a h using rpc_port_parcel_destroy(). * @param[out] h The rpc port parcel handle that is newly created * @return @c 0 on success, @@ -61,7 +61,7 @@ int rpc_port_parcel_create(rpc_port_parcel_h *h); * @brief Creates a rpc port parcel handle from port. * @details Creates a rpc port parcel handle using read data from the port. * It calls rpc_port_read() internally. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks You must release @a h using rpc_port_parcel_destroy(). * @param[out] h The rpc port parcel handle that is newly created * @param[in] port The rpc port handle for creating handle @@ -79,7 +79,7 @@ int rpc_port_parcel_create_from_port(rpc_port_parcel_h *h, rpc_port_h port); * @brief Sends parcel data through the port. * @details Sends parcel data through the port. It calls rpc_port_write() * internally. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle that is newly created * @param[in] port The rpc port handle for writing data * @return @c 0 on success, @@ -93,7 +93,7 @@ int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port); /** * @brief Destroys a rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @return @c 0 on success, * otherwise a negative error value @@ -105,7 +105,7 @@ int rpc_port_parcel_destroy(rpc_port_parcel_h h); /** * @brief Writes a byte value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] b Byte data * @return @c 0 on success, @@ -118,7 +118,7 @@ int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b); /** * @brief Writes a short value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] i short data * @return @c 0 on success, @@ -131,7 +131,7 @@ int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i); /** * @brief Writes a integer value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] i int data * @return @c 0 on success, @@ -144,7 +144,7 @@ int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i); /** * @brief Writes a long long integer value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] i long long data * @return @c 0 on success, @@ -157,7 +157,7 @@ int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i); /** * @brief Writes a floating point value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] f float data * @return @c 0 on success, @@ -170,7 +170,7 @@ int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f); /** * @brief Writes a double precision floating point value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] d double data * @return @c 0 on success, @@ -183,7 +183,7 @@ int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d); /** * @brief Writes a string value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] str string data * @return @c 0 on success, @@ -196,7 +196,7 @@ int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char *str); /** * @brief Writes a boolean value into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] b boolean data * @return @c 0 on success, @@ -209,7 +209,7 @@ int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b); /** * @brief Writes a bundle data into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] b Bundle data * @return @c 0 on success, @@ -222,7 +222,7 @@ int rpc_port_parcel_write_bundle(rpc_port_parcel_h h, bundle *b); /** * @brief Writes a count for array into rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] count Array count * @return @c 0 on success, @@ -235,7 +235,7 @@ int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count); /** * @brief Writes the data into parcel handle using @a parcelable. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] parcelable The interface to write the data into parcel handle * @param[in] data Data which write into parcel @@ -249,7 +249,7 @@ int rpc_port_parcel_write(rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable /** * @brief Reads a byte value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] b Byte data * @return @c 0 on success, @@ -262,7 +262,7 @@ int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char *b); /** * @brief Reads a short value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] i short data * @return @c 0 on success, @@ -275,7 +275,7 @@ int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short *i); /** * @brief Reads a integer value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] i int data * @return @c 0 on success, @@ -288,7 +288,7 @@ int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int *i); /** * @brief Reads a long long integer value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] i long long data * @return @c 0 on success, @@ -301,7 +301,7 @@ int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long *i); /** * @brief Reads a floating point value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] f float data * @return @c 0 on success, @@ -314,7 +314,7 @@ int rpc_port_parcel_read_float(rpc_port_parcel_h h, float *f); /** * @brief Reads a double precision floating point value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] d double data * @return @c 0 on success, @@ -327,7 +327,7 @@ int rpc_port_parcel_read_double(rpc_port_parcel_h h, double *d); /** * @brief Reads a string value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks The @a str should be released using free(). * @param[in] h The rpc port parcel handle * @param[out] str string data @@ -341,7 +341,7 @@ int rpc_port_parcel_read_string(rpc_port_parcel_h h, char **str); /** * @brief Reads a boolean value from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] b boolean data * @return @c 0 on success, @@ -354,7 +354,7 @@ int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool *b); /** * @brief Reads a bundle data from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks The @a b should be released using bundle_free(). * @param[in] h The rpc port parcel handle * @param[out] b Bundle data @@ -368,7 +368,7 @@ int rpc_port_parcel_read_bundle(rpc_port_parcel_h h, bundle **b); /** * @brief Reads a count for array from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] count Array count * @return @c 0 on success, @@ -381,7 +381,7 @@ int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int *count); /** * @brief Reads a parcel from the data using @a parcelable. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] parcelable The interface to get data from parcel handle * @param[in] data Data which get from parcel @@ -396,7 +396,7 @@ int rpc_port_parcel_read(rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable, /** * @brief Reads bytes from rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[out] buf The array buffer to read * @param[in] size Bytes to read @@ -410,7 +410,7 @@ int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char *buf, unsigned /** * @brief Write bytes to rpc port parcel handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port parcel handle * @param[in] buf The array buffer to write * @param[in] size Bytes to write diff --git a/include/rpc-port.h b/include/rpc-port.h index f14aac0..559141b 100755 --- a/include/rpc-port.h +++ b/include/rpc-port.h @@ -32,7 +32,7 @@ extern "C" { /** * @brief Enumeration for error codes of a rpc port. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef enum { RPC_PORT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ @@ -44,7 +44,7 @@ typedef enum { /** * @brief Enumeration for types of communication channels. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef enum { RPC_PORT_PORT_MAIN, /**< Main channel */ @@ -55,13 +55,13 @@ typedef enum { /** * @brief The rpc port handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef void *rpc_port_h; /** * @brief Reads data from an RPC port. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * * @param[in] h The rpc port handle * @param[out] buf Buffer for reading data @@ -78,7 +78,7 @@ int rpc_port_read(rpc_port_h h, void *buf, unsigned int size); /** * @brief Writes data to an RPC port. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * * @param[in] h The rpc port handle * @param[in] buf Buffer for writing data @@ -99,7 +99,7 @@ int rpc_port_write(rpc_port_h h, const void *buf, unsigned int size); /** * @brief Called when the proxy is connected. * @details The function is called when the proxy is connected with stub by port. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] receiver The target stub app id * @param[in] port_name The name of the port * @param[in] port The rpc port handle for reading and writing @@ -111,7 +111,7 @@ typedef void (*rpc_port_proxy_connected_event_cb)(const char *receiver, /** * @brief Called when the proxy is disconnected. * @details The function is called when the proxy is disconnected from stub. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] receiver The target stub app id * @param[in] port_name The name of the port * @param[in] user_data The user data passed from the register function @@ -122,7 +122,7 @@ typedef void (*rpc_port_proxy_disconnected_event_cb)(const char *receiver, /** * @brief Called when the proxy is rejected. * @details The function is called when the proxy is rejected to connect stub. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] receiver The target stub app id * @param[in] port_name The name of the port * @param[in] user_data The user data passed from the register function @@ -133,7 +133,7 @@ typedef void (*rpc_port_proxy_rejected_event_cb)(const char *receiver, /** * @brief Called when the proxy received data. * @details The function is called when the proxy received data from stub. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] receiver The target stub app id * @param[in] port_name The name of the port * @param[in] user_data The user data passed from the register function @@ -143,13 +143,13 @@ typedef void (*rpc_port_proxy_received_event_cb)(const char *receiver, /** * @brief The rpc port proxy handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef void *rpc_port_proxy_h; /** * @brief Creates a rpc port proxy handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks You must release @a h using rpc_port_proxy_destroy(). * @param[out] h The rpc port proxy handle that is newly created * @return @c 0 on success, @@ -162,7 +162,7 @@ int rpc_port_proxy_create(rpc_port_proxy_h *h); /** * @brief Destroys a rpc port proxy handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port proxy handle * @return @c 0 on success, * otherwise a negative error value @@ -175,7 +175,7 @@ int rpc_port_proxy_destroy(rpc_port_proxy_h h); /** * @brief Connects to @a port of @a appid. * @details To send and receive data, the proxy should connect to port of stub - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch \n * %http://tizen.org/privilege/datasharing @@ -195,7 +195,7 @@ int rpc_port_proxy_connect(rpc_port_proxy_h h, const char *appid, /** * @brief Adds a proxy connected callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port proxy handle * @param[in] cb The callback function to be called when proxy is connected * @param[in] user_data The user data to be passed to @@ -210,7 +210,7 @@ int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h, /** * @brief Adds a proxy disconnected callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port proxy handle * @param[in] cb The callback function to be called when proxy is disconnected * @param[in] user_data The user data to be passed to @@ -225,7 +225,7 @@ int rpc_port_proxy_add_disconnected_event_cb(rpc_port_proxy_h h, /** * @brief Adds a proxy rejected callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port proxy handle * @param[in] cb The callback function to be called when proxy is rejected * @param[in] user_data The user data to be passed to @@ -240,7 +240,7 @@ int rpc_port_proxy_add_rejected_event_cb(rpc_port_proxy_h h, /** * @brief Adds a proxy received callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port proxy handle * @param[in] cb The callback function to be called when proxy received data * @param[in] user_data The user data to be passed to @@ -255,7 +255,7 @@ int rpc_port_proxy_add_received_event_cb(rpc_port_proxy_h h, /** * @brief Gets a port from proxy handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks This handle @a port will not be valid if the proxy was disconnected or destroyed. * @param[in] h The rpc port proxy handle * @param[in] type The type of port @@ -277,7 +277,7 @@ int rpc_port_proxy_get_port(rpc_port_proxy_h h, rpc_port_port_type_e type, /** * @brief The rpc port stub handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif */ typedef void *rpc_port_stub_h; @@ -286,7 +286,7 @@ typedef void *rpc_port_stub_h; * @details The function is called when the proxy is connected with stub. * When a proxy connects to stub several times with new port, * you can handle each request by using @a instance. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] sender The target proxy app id * @param[in] instance The information of the request * @param[in] user_data The user data passed from the register function @@ -299,7 +299,7 @@ typedef void (*rpc_port_stub_connected_event_cb)(const char *sender, * @details The function is called when the proxy is disconnected from stub. * When a proxy is disconnected, you can check the request * by using @a instance. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] sender The target proxy app id * @param[in] instance The information of the request * @param[in] user_data The user data passed from the register function @@ -313,7 +313,7 @@ typedef void (*rpc_port_stub_disconnected_event_cb)(const char *sender, * When a stub received data from several ports, you can handle * each request by using @a instance. If the function returns non zero * value, the stub is disconnected. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] sender The target proxy app id * @param[in] instance The information of the request * @param[in] port The rpc port handle for reading and writing @@ -326,7 +326,7 @@ typedef int (*rpc_port_stub_received_event_cb)(const char *sender, /** * @brief Creates a rpc port stub handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks You must release @a h using rpc_port_stub_destroy(). * @param[out] h The rpc port stub handle that is newly created * @param[in] port_name The name of the port which want to listen @@ -340,7 +340,7 @@ int rpc_port_stub_create(rpc_port_stub_h *h, const char *port_name); /** * @brief Destroys a rpc port stub handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @return @c 0 on success, * otherwise a negative error value @@ -353,7 +353,7 @@ int rpc_port_stub_destroy(rpc_port_stub_h h); /** * @brief Listens to the requests for connections. * @details The stub listens requests to connect by port - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @return @c 0 on success, * otherwise a negative error value @@ -367,7 +367,7 @@ int rpc_port_stub_listen(rpc_port_stub_h h); * @brief Adds a privilege to the stub. * @details The stub can control access to the port using tizen privilege. * It allows connections only if the proxy which have the privileges. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @param[in] privilege The privilege to access this stub * @return @c 0 on success, @@ -382,7 +382,7 @@ int rpc_port_stub_add_privilege(rpc_port_stub_h h, const char *privilege); * @details The stub can control access to the port using tizen certificate. * It allows connections only if the proxy is signed with the same * certificate. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @param[in] trusted Whether stub allows only trusted proxy or not * @return @c 0 on success, @@ -394,7 +394,7 @@ int rpc_port_stub_set_trusted(rpc_port_stub_h h, const bool trusted); /** * @brief Adds a stub connected callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc stub stub handle * @param[in] cb The callback function to be called when proxy is connected * with the stub @@ -410,7 +410,7 @@ int rpc_port_stub_add_connected_event_cb(rpc_port_stub_h h, /** * @brief Adds a stub disconnected callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @param[in] cb The callback function to be called when proxy is disconnected * with the stub @@ -426,7 +426,7 @@ int rpc_port_stub_add_disconnected_event_cb(rpc_port_stub_h h, /** * @brief Adds a stub received callback. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @param[in] h The rpc port stub handle * @param[in] cb The callback function to be called when stub received data * @param[in] user_data The user data to be passed to @@ -441,7 +441,7 @@ int rpc_port_stub_add_received_event_cb(rpc_port_stub_h h, /** * @brief Gets a port from stub handle. - * @since_tizen 4.0 + * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif * @remarks This handle @a port will not be valid if the instance of the stub was disconnected or destroyed. * @param[in] h The rpc port stub handle * @param[in] type The type of port -- 2.7.4 From c7c0783f3d0f1cf3e537493955c3aff84c97f6f3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 13 Aug 2018 12:09:40 +0900 Subject: [PATCH 07/16] Release version 1.2.4 Changes: - Remove unreachable code - Modified the description Change-Id: I4852ba4f515e08989be5c1af07c827da63339734 Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index 87a99e4..384c6cb 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.2.2 +Version: 1.2.4 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 62cce3db547d09a0fb330c0168f331e339c5025c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 12 Oct 2018 08:55:20 +0900 Subject: [PATCH 08/16] Fixed port registration Getting owner ID is called after registering interface. When stub is getting owner ID, name appeared callback function of proxy is invoked. Change-Id: Ic53aef2b873b774ee510f3322d2af63ab5b706f6 Signed-off-by: Hwankyu Jhun --- src/fdbroker-internal.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fdbroker-internal.cc b/src/fdbroker-internal.cc index 2c183a3..aa234c7 100644 --- a/src/fdbroker-internal.cc +++ b/src/fdbroker-internal.cc @@ -462,12 +462,6 @@ int FdBroker::RegisterDbusInterface(const std::string& port_name) { return -1; std::string interface_name = GetInterfaceName(appid, port_name); - - if (GetOwnerId(interface_name) < 0) { - LOGE("Failed to get owner id"); - return -1; - } - std::string introspection_xml = introspection_prefix + interface_name + introspection_postfix; @@ -490,6 +484,13 @@ int FdBroker::RegisterDbusInterface(const std::string& port_name) { return -1; } + if (GetOwnerId(interface_name) < 0) { + LOGE("Failed to get owner id"); + return -1; + } + + LOGI("%s is registered", port_name); + return 0; } -- 2.7.4 From cb9db6fff2891de5789fa19fd4de4053bf52e1fa Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 17 Oct 2018 15:38:43 +0900 Subject: [PATCH 09/16] Change parameter types to use move semantic Change-Id: Ie3788d5e616353640b47c150941139198453897f Signed-off-by: Junghoon Park --- src/proxy-internal.cc | 10 +++++----- src/proxy-internal.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 4830f42..262634b 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -124,8 +124,8 @@ void Proxy::OnPortVanished(const std::string& appid, appid.c_str(), port_name.c_str()); } -int Proxy::Connect(const std::string appid, const std::string& port_name, - IEventListener* ev) { +int Proxy::Connect(std::string appid, std::string port_name, + IEventListener* ev) { if (ev == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER; @@ -135,9 +135,9 @@ int Proxy::Connect(const std::string appid, const std::string& port_name, } listener_ = ev; - target_appid_ = appid; - port_name_ = port_name; - int r = fd_broker_.Watch(this, appid, port_name); + target_appid_ = std::move(appid); + port_name_ = std::move(port_name); + int r = fd_broker_.Watch(this, target_appid_, port_name_); if (r < 0) { listener_ = nullptr; if (r == -EILLEGALACCESS) diff --git a/src/proxy-internal.h b/src/proxy-internal.h index f5768ed..8584ca2 100644 --- a/src/proxy-internal.h +++ b/src/proxy-internal.h @@ -43,11 +43,12 @@ class Proxy : public FdBroker::IEventWatcher { virtual void OnReceived(const std::string& endpoint) = 0; }; - int Connect(const std::string appid, const std::string& port_name, - IEventListener* ev); + int Connect(std::string appid, std::string port_name, IEventListener* ev); + std::shared_ptr GetPort() const { return main_port_; } + std::shared_ptr GetDelegatePort() const { return delegate_port_; } -- 2.7.4 From 6c65ac3ecd9ba219812243e2d4cac07eea2004e7 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 1 Nov 2018 17:27:10 +0900 Subject: [PATCH 10/16] Fixed wrong timeout interval Change-Id: I8413cb5f8288e7743edd2643b7899cde05b9b26a Signed-off-by: Hwankyu Jhun --- src/port-internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port-internal.cc b/src/port-internal.cc index 7733afd..2cd3a72 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -119,7 +119,7 @@ int Port::Write(const void* buf, unsigned int size) { fds[0].revents = 0; clock_gettime(CLOCK_MONOTONIC, &start_time); - ret = poll(fds, 1, MAX_SLEEP * 1000); + ret = poll(fds, 1, MAX_SLEEP * MAX_CNT); clock_gettime(CLOCK_MONOTONIC, &end_time); if (ret == 0) { LOGE("write_socket: : fd %d poll timeout", fd_); -- 2.7.4 From 3035ab50785a3798393a98011aa749bf93b1b03a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 1 Nov 2018 19:36:48 +0900 Subject: [PATCH 11/16] Release version 1.3.0 Changes: - Fixed port registration - Change parameter types to use move semantic - Fixed wrong timeout interval Change-Id: I3074e2a55623aff1effccf886d7023bdd8045afa Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index 384c6cb..bbe58c2 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.2.4 +Version: 1.3.0 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From a852bac3c4c63637206655903c5af2766ada4a02 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 2 Nov 2018 13:47:07 +0900 Subject: [PATCH 12/16] Fix socket pair requests Requires: - https://review.tizen.org/gerrit/#/c/192266/ [amd] - https://review.tizen.org/gerrit/#/c/192286/ [aul-1] - https://review.tizen.org/gerrit/#/c/192287/ [rpc-port] Change-Id: I2946e94cd5d27db859eec809ef610b6bbc90c079 Signed-off-by: Hwankyu Jhun --- src/fdbroker-internal.cc | 10 ++++++---- src/fdbroker-internal.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fdbroker-internal.cc b/src/fdbroker-internal.cc index aa234c7..010d555 100644 --- a/src/fdbroker-internal.cc +++ b/src/fdbroker-internal.cc @@ -143,12 +143,14 @@ FdBroker::SocketPair::~SocketPair() { close(socks_[RECEIVER]); } -int FdBroker::SocketPair::Request() { +int FdBroker::SocketPair::Request(const std::string& target_appid, + const std::string& port_name) { if (mock_) { return socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, socks_); } - if (aul_rpc_port_create_socket_pair(&socks_) != AUL_R_OK) { + if (aul_rpc_port_create_socket_pair(target_appid.c_str(), + port_name.c_str(), &socks_) != AUL_R_OK) { LOGE("error create socket pair"); return -1; } @@ -243,9 +245,9 @@ int FdBroker::Send(const std::string& target_appid, return -1; } - if (main_sock_pair.Request() != 0) + if (main_sock_pair.Request(target_appid, port_name) != 0) return -1; - if (delegate_sock_pair.Request() != 0) + if (delegate_sock_pair.Request(target_appid, port_name) != 0) return -1; if (mock_) { diff --git a/src/fdbroker-internal.h b/src/fdbroker-internal.h index e9b15b8..510c992 100644 --- a/src/fdbroker-internal.h +++ b/src/fdbroker-internal.h @@ -115,7 +115,7 @@ class FdBroker { explicit SocketPair(bool mock = false); ~SocketPair(); - int Request(); + int Request(const std::string& target_appid, const std::string& port_name); void RequestMock(); int Get(Type t) const; int Detach(Type t); -- 2.7.4 From 0fb36d62214d4e2fc45ddf7bf72d5388845d9278 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 2 Nov 2018 13:59:35 +0900 Subject: [PATCH 13/16] Fix wrong parameter Change-Id: I52f78ae7c99380bcc7e6ec218b9017c0303f591f Signed-off-by: Hwankyu Jhun --- src/fdbroker-internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fdbroker-internal.cc b/src/fdbroker-internal.cc index 010d555..ad14b96 100644 --- a/src/fdbroker-internal.cc +++ b/src/fdbroker-internal.cc @@ -491,7 +491,7 @@ int FdBroker::RegisterDbusInterface(const std::string& port_name) { return -1; } - LOGI("%s is registered", port_name); + LOGI("%s is registered", port_name.c_str()); return 0; } -- 2.7.4 From ac15051f77cd65d671f945511a2c33393fa11e6c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 5 Nov 2018 18:43:50 +0900 Subject: [PATCH 14/16] Release version 1.3.1 Changes: - Fix socket pair requests - Fix wrong parameter Change-Id: Ib89ee2e8a9c32c104944db2f5c3abc22b32fa4b1 Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index bbe58c2..70f75e1 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.3.0 +Version: 1.3.1 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 79ab22a87c9043f5b9747f55d9d0c91c8d294c0b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 26 Nov 2018 15:33:06 +0900 Subject: [PATCH 15/16] Handle EPIPE error The Write() Method uses send() with MSG_NOSIGNAL instead of write(). Change-Id: I20251df65375dacdc42f9a4da1d531dd3e635728 Signed-off-by: Hwankyu Jhun --- src/port-internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port-internal.cc b/src/port-internal.cc index 2cd3a72..34557b6 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -134,7 +134,7 @@ int Port::Write(const void* buf, unsigned int size) { } while (left) { - nb = write(fd_, buffer, left); + nb = send(fd_, buffer, left, MSG_NOSIGNAL); if (nb == -1) { if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { LOGE("write_socket: %d errno, sleep and retry ...", errno); -- 2.7.4 From 4eaa33eab6dad750f314515a05ee678b07293a6e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 26 Nov 2018 16:59:17 +0900 Subject: [PATCH 16/16] Release version 1.3.2 Changes: - Handle EPIPE error Change-Id: Ie086bdbad897a6149640a4175660b05065f91e30 Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index 70f75e1..74f6330 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -1,6 +1,6 @@ Name: rpc-port Summary: RPC Port library -Version: 1.3.1 +Version: 1.3.2 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4