From d1eeb43d618c1e4379c72ed9692c0bc478bb8b2a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 7 Dec 2018 14:14:09 +0900 Subject: [PATCH 01/16] Release version 1.3.3 Changes: - Fix a wrong log format Change-Id: Ib7e40d6f313f9f6f1b9402d1759feb6d91464493 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 74f6330..d58490c 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.2 +Version: 1.3.3 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 9352c724da8a0e73811baa33ade9067649f3ca78 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 10 Dec 2018 17:54:21 +0900 Subject: [PATCH 02/16] Fix Unit Test The package name is changed to "rpc-port-unittests". The executable file name is changed to "rpc-port_unittests". The descriptions are added. Change-Id: I7bccadd241f938f7ebd75ea0d82a5932fcdfbf5d Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 10 ++-- unit_tests/CMakeLists.txt | 10 ++-- unit_tests/src/rpc_port_parcel_test.cc | 91 +++++++++++++++++++++++++++++----- unit_tests/src/rpc_port_test.cc | 45 +++++++++++++++-- 4 files changed, 129 insertions(+), 27 deletions(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index d58490c..df1d35d 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -66,15 +66,15 @@ rm -rf %{buildroot} %{_libdir}/lib%{name}.so ################################################# -# gtest-rpc-port +# rpc-port-unittests ################################################# -%package -n gtest-rpc-port +%package -n rpc-port-unittests Summary: GTest for rpc-port Group: Development/Libraries Requires: %{name} -%description -n gtest-rpc-port +%description -n rpc-port-unittests GTest for rpc-port -%files -n gtest-rpc-port -%{_bindir}/gtest-rpc-port +%files -n rpc-port-unittests +%{_bindir}/rpc-port_unittests diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index ecbe1b6..a3b19c4 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -1,14 +1,14 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(gtest-rpc-port CXX) +PROJECT(rpc-port_unittests CXX) INCLUDE(FindPkgConfig) -pkg_check_modules(gtest-rpc-port REQUIRED +pkg_check_modules(rpc-port_unittests REQUIRED glib-2.0 gmock aul ) -FOREACH(flag ${gtest-rpc-port_CFLAGS}) +FOREACH(flag ${rpc-port_unittests_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") @@ -25,6 +25,6 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES} ) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest-rpc-port_LDFLAGS} rpc-port) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpc-port_unittests_LDFLAGS} rpc-port) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin) diff --git a/unit_tests/src/rpc_port_parcel_test.cc b/unit_tests/src/rpc_port_parcel_test.cc index 21e11c4..a04d6a1 100644 --- a/unit_tests/src/rpc_port_parcel_test.cc +++ b/unit_tests/src/rpc_port_parcel_test.cc @@ -101,7 +101,12 @@ class ParcelTest : public ::testing::Test { bool touch_to_ = false; }; -TEST(rpc_port_parcel, rpc_port_parcel_create_destroy) { +/* + * @testcase rpc_port_parcel_create_destroy_P + * @description Creates and destroys the rpc-port parcel handle + * @apicovered rpc_port_parcel_create, rpc_port_parcel_destroy + */ +TEST(rpc_port_parcel, rpc_port_parcel_create_destroy_P) { rpc_port_parcel_h handle; int ret = rpc_port_parcel_create(&handle); @@ -113,7 +118,12 @@ TEST(rpc_port_parcel, rpc_port_parcel_create_destroy) { ASSERT_EQ(ret, 0); } -TEST_F(ParcelTest, read_write_byte) { +/* + * @testcase rpc_port_parcel_read_write_byte_P + * @description Writes and reads the byte data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_byte, rpc_port_parcel_read_byte + */ +TEST_F(ParcelTest, rpc_port_parcel_write_read_byte_P) { int ret = rpc_port_parcel_write_byte(handle_, 'k'); ASSERT_EQ(ret, 0); @@ -123,7 +133,12 @@ TEST_F(ParcelTest, read_write_byte) { ASSERT_EQ(b, 'k'); } -TEST_F(ParcelTest, read_write_int16) { +/* + * @testcase rpc_port_parcel_read_write_int16_P + * @description Writes and reads the int16 data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_int16, rpc_port_parcel_read_int16 + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_in16_P) { int ret = rpc_port_parcel_write_int16(handle_, 123); ASSERT_EQ(ret, 0); @@ -133,7 +148,12 @@ TEST_F(ParcelTest, read_write_int16) { ASSERT_EQ(b, 123); } -TEST_F(ParcelTest, read_write_int32) { +/* + * @testcase rpc_port_parcel_read_write_int32_P + * @description Writes and reads the int32 data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_int32, rpc_port_parcel_read_int32 + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_int32_P) { int ret = rpc_port_parcel_write_int32(handle_, 123456); ASSERT_EQ(ret, 0); @@ -143,7 +163,12 @@ TEST_F(ParcelTest, read_write_int32) { ASSERT_EQ(b, 123456); } -TEST_F(ParcelTest, read_write_int64) { +/* + * @testcase rpc_port_parcel_read_write_int64_P + * @description Writes and reads the int64 data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_int64, rpc_port_parcel_read_int64 + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_int64_P) { int ret = rpc_port_parcel_write_int64(handle_, 12345678); ASSERT_EQ(ret, 0); @@ -153,7 +178,12 @@ TEST_F(ParcelTest, read_write_int64) { ASSERT_EQ(b, 12345678); } -TEST_F(ParcelTest, read_write_float) { +/* + * @testcase rpc_port_parcel_read_write_float_P + * @description Writes and reads the float data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_float, rpc_port_parcel_read_float + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_float_P) { int ret = rpc_port_parcel_write_float(handle_, 123.456f); ASSERT_EQ(ret, 0); @@ -163,7 +193,12 @@ TEST_F(ParcelTest, read_write_float) { ASSERT_EQ(b, 123.456f); } -TEST_F(ParcelTest, read_write_double) { +/* + * @testcase rpc_port_parcel_read_write_double_P + * @description Writes and reads the double data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_double, rpc_port_parcel_read_double + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_double_P) { int ret = rpc_port_parcel_write_double(handle_, 123.456f); ASSERT_EQ(ret, 0); @@ -173,7 +208,12 @@ TEST_F(ParcelTest, read_write_double) { ASSERT_EQ(b, 123.456f); } -TEST_F(ParcelTest, read_write_string) { +/* + * @testcase rpc_port_parcel_read_write_string_P + * @description Writes and reads the string data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_string, rpc_port_parcel_read_string + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_string_P) { const char str[] = "abcdef"; int ret = rpc_port_parcel_write_string(handle_, str); ASSERT_EQ(ret, 0); @@ -185,7 +225,12 @@ TEST_F(ParcelTest, read_write_string) { ASSERT_STREQ(s1.Get(), str); } -TEST_F(ParcelTest, read_write_bool) { +/* + * @testcase rpc_port_parcel_read_write_bool_P + * @description Writes and reads the boolean data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_bool, rpc_port_parcel_read_bool + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_bool_P) { int ret = rpc_port_parcel_write_bool(handle_, true); ASSERT_EQ(ret, 0); @@ -195,7 +240,12 @@ TEST_F(ParcelTest, read_write_bool) { ASSERT_TRUE(b); } -TEST_F(ParcelTest, read_write_bundle) { +/* + * @testcase rpc_port_parcel_read_write_bundle_P + * @description Writes and reads the bundle data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_bundle, rpc_port_parcel_read_bundle + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_bundle_P) { bundle* b = bundle_create(); ASSERT_NE(b, nullptr); @@ -218,7 +268,12 @@ TEST_F(ParcelTest, read_write_bundle) { ASSERT_STREQ("Value", str); } -TEST_F(ParcelTest, read_write_array_count) { +/* + * @testcase rpc_port_parcel_read_write_array_count_P + * @description Writes and reads the array count data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write_array_count, rpc_port_parcel_read_array_count + */ +TEST_F(ParcelTest, rpc_port_parcle_read_write_array_count_P) { int ret = rpc_port_parcel_write_array_count(handle_, 123); ASSERT_EQ(ret, 0); @@ -228,7 +283,12 @@ TEST_F(ParcelTest, read_write_array_count) { ASSERT_EQ(c, 123); } -TEST_F(ParcelTest, read_write) { +/* + * @testcase rpc_port_parcel_read_write_P + * @description Writes and reads the data to the rpc-port parcel handle + * @apicovered rpc_port_parcel_write, rpc_port_parcel_read + */ +TEST_F(ParcelTest, rpc_port_parcel_read_write_P) { rpc_port_parcelable_t p = { .to = WriteParcelable, .from = ReadParcelable @@ -243,7 +303,12 @@ TEST_F(ParcelTest, read_write) { ASSERT_TRUE(touch_from_); } -TEST_F(ParcelTest, burst_read_write) { +/* + * @testcase rpc_port_parcel_burst_read_write_P + * @description Writes and reads the data by burst mode to the rpc-port parcel handle + * @apicovered rpc_port_parcel_burst_write, rpc_port_parcel_burst_read + */ +TEST_F(ParcelTest, rpc_port_parcel_burst_read_write_P) { unsigned char buf[] = { 0, 1, 2, 3, 4 }; int ret = rpc_port_parcel_burst_write(handle_, buf, sizeof(buf)); ASSERT_EQ(ret, 0); diff --git a/unit_tests/src/rpc_port_test.cc b/unit_tests/src/rpc_port_test.cc index dd2dc87..601f4c4 100644 --- a/unit_tests/src/rpc_port_test.cc +++ b/unit_tests/src/rpc_port_test.cc @@ -168,6 +168,13 @@ class RpcPortConnection : public RpcPortBase { bool touch_proxy_received_event_cb_ = false; }; +/* + * @testcase rpc_port_event_connect_P + * @description After the rpc_port_proxy_connect() is called, + * the rambda function is called by connected events. + * @apicovered rpc_port_stub_add_connected_event_cb, rpc_port_stub_listen, + * rpc_port_proxy_add_connected_event_cb, rpc_port_proxy_connect, + */ TEST_F(RpcPortBase, rpc_port_event_connect) { int ret = rpc_port_stub_add_connected_event_cb(stub_handle_, [](const char *sender, const char* instance, void *data) { @@ -195,7 +202,14 @@ TEST_F(RpcPortBase, rpc_port_event_connect) { ASSERT_TRUE(touch_stub_connected_event_cb_); } -TEST_F(RpcPortBase, rpc_port_proxy_event_reject) { +/* + * @testcase rpc_port_proxy_event_reject_n + * @description After the rpc_port_proxy_connect() is called, + * the rambda function is called by the rejected event. + * @apicovered rpc_port_stub_listen, rpc_port_proxy_add_connected_event_cb, + * rpc_port_proxy_connect, + */ +TEST_F(RpcPortBase, rpc_port_proxy_event_reject_N) { int ret = rpc_port_stub_listen(stub_handle_); ASSERT_EQ(ret, 0); @@ -213,7 +227,13 @@ TEST_F(RpcPortBase, rpc_port_proxy_event_reject) { ASSERT_TRUE(touch_proxy_rejected_event_cb_); } -TEST_F(RpcPortConnection, rpc_port_proxy_event_receive) { +/* + * @testcase rpc_port_proxy_event_receive_P + * @description Writes and reads the data to the port handles. + * And then, checks the data in callback functions. + * @apicovered rpc_port_write, rpc_port_read + */ +TEST_F(RpcPortConnection, rpc_port_proxy_event_receive_p) { char res[] = "OK"; char r_buf[256]; @@ -247,6 +267,11 @@ TEST_F(RpcPortConnection, rpc_port_proxy_event_receive) { ASSERT_STREQ(res, r_buf); } +/* + * @testcase rpc_port_read_write_P + * @description Writes and reads the data to the port handles. + * @apicovered rpc_port_write, rpc_port_read + */ TEST_F(RpcPortConnection, rpc_port_read_write) { char buf[] = "test message"; char res[] = "OK"; @@ -271,14 +296,26 @@ TEST_F(RpcPortConnection, rpc_port_read_write) { ASSERT_STREQ("OK", r_buf); } -TEST_F(RpcPortConnection, rpc_port_proxy_disconnected) { +/* + * @testcase rpc_port_proxy_disconnected_N + * @description Kills the stub port. + * And then, checks whether the disconnected event callback is invoked or not. + * @apicovered rpc_port_stub_add_disconnected_event_cb + */ +TEST_F(RpcPortConnection, rpc_port_proxy_disconnected_N) { KillStub(); RunMainLoop(); ASSERT_TRUE(touch_proxy_disconnected_event_cb_); } -TEST_F(RpcPortConnection, rpc_port_stub_disconnected) { +/* + * @testcase rpc_port_stub_disconnected_N + * @description Kills the proxy port. + * And then, checks whether the disconnected event callback is invoked or not. + * @apicovered rpc_port_proxy_add_disconnected_event_cb + */ +TEST_F(RpcPortConnection, rpc_port_stub_disconnected_N) { KillProxy(); RunMainLoop(); -- 2.7.4 From 53d7dd8ec044fb11477e4359317e99baadb061a8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 14 Dec 2018 16:04:18 +0900 Subject: [PATCH 03/16] Make a gcov package for coverage measurement Change-Id: Ibd38571573dead9c202543ea8ca43bd98849b893 Signed-off-by: Hwankyu Jhun --- packaging/rpc-port.spec | 61 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/packaging/rpc-port.spec b/packaging/rpc-port.spec index df1d35d..3689a4e 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -35,26 +35,71 @@ Requires: %{name} = %{version}-%{release} %description devel RPC Port library (Development) package. +################################################# +# rpc-port-unittests +################################################# +%package -n rpc-port-unittests +Summary: GTest for rpc-port +Group: Development/Libraries +Requires: %{name} + +%description -n rpc-port-unittests +GTest for rpc-port + +################################################# +# rpc-port-gcov +################################################# +%if 0%{?gcov:1} +%package gcov +Summary: RPC Port(gcov) +Group: Application Framework/Testing + +%description gcov +RPC Port gcov objects +%endif + %prep %setup -q cp %{SOURCE1001} . %build +%if 0%{?gcov:1} +export CFLAGS+=" -fprofile-arcs -ftest-coverage" +export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" +export FFLAGS+=" -fprofile-arcs -ftest-coverage" +export LDFLAGS+=" -lgcov" +%endif + MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} # Call make instruction with smp support %__make %{?jobs:-j%jobs} +%if 0%{?gcov:1} +mkdir -p gcov-obj +find . -name '*.gcno' -exec cp '{}' gcov-obj ';' +%endif + %install rm -rf %{buildroot} %make_install +%if 0%{?gcov:1} +mkdir -p %{buildroot}%{_datadir}/gcov/obj +install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +%endif + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig +%post -n rpc-port-unittests +%if 0%{?gcov:1} +%{_bindir}/rpc-port_unittests +%endif + %files %manifest %{name}.manifest %attr(0644,root,root) %{_libdir}/lib%{name}.so.* @@ -68,13 +113,13 @@ rm -rf %{buildroot} ################################################# # rpc-port-unittests ################################################# -%package -n rpc-port-unittests -Summary: GTest for rpc-port -Group: Development/Libraries -Requires: %{name} - -%description -n rpc-port-unittests -GTest for rpc-port - %files -n rpc-port-unittests %{_bindir}/rpc-port_unittests + +################################################# +# rpc-port-gcov +################################################# +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/obj/* +%endif -- 2.7.4 From 595c7a6cbf71727b62456316581ca093844b769a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 14 Dec 2018 17:14:24 +0900 Subject: [PATCH 04/16] Release version 1.3.4 Changes: - Fix Unit Test - Make a gcov package for coverage measurement Change-Id: I58bc0f42395b09ac9edb03baa91a66a7c1caff57 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 3689a4e..06b4e16 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.3 +Version: 1.3.4 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 499cde7eea263eaf82c323ae413ed16a6c607f60 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 11 Feb 2019 12:36:51 +0900 Subject: [PATCH 05/16] Adjust log level Change-Id: Ib497cdb84b0ff3186f05090bf2e963229954d4bf Signed-off-by: Hwankyu Jhun --- src/ac-internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ac-internal.cc b/src/ac-internal.cc index f2e728b..89138ca 100644 --- a/src/ac-internal.cc +++ b/src/ac-internal.cc @@ -161,7 +161,7 @@ int AccessController::Cynara::Check(const std::string& privilege) const { LOGD("check privilege %s", privilege.c_str()); if (cynara_check(cynara_, client_, "", user_, privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) { - LOGD("cynara_check() is not allowed : %s", privilege.c_str()); + LOGE("cynara_check() is not allowed : %s", privilege.c_str()); return -1; } -- 2.7.4 From 053c439cfe19179f2d5ab4caf6d3d36b7d88932e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 11 Feb 2019 15:20:52 +0900 Subject: [PATCH 06/16] Release version 1.3.5 Changes: - Adjust log level Change-Id: I9943d5b4477f3bfa30916960daa0c3d14fb38ebf 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 06b4e16..675e137 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.4 +Version: 1.3.5 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From a1f0c346bb4de24d036e9f13eb02f813e11e1b65 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Mon, 11 Feb 2019 17:46:34 +0900 Subject: [PATCH 07/16] Fix static analysis issues Change-Id: If83771089ef803f9f8da21168aac85f26431663e Signed-off-by: Junghoon Park --- unit_tests/src/rpc_port_parcel_test.cc | 2 +- unit_tests/src/rpc_port_test.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/unit_tests/src/rpc_port_parcel_test.cc b/unit_tests/src/rpc_port_parcel_test.cc index a04d6a1..2b67502 100644 --- a/unit_tests/src/rpc_port_parcel_test.cc +++ b/unit_tests/src/rpc_port_parcel_test.cc @@ -259,8 +259,8 @@ TEST_F(ParcelTest, rpc_port_parcel_read_write_bundle_P) { b = nullptr; ret = rpc_port_parcel_read_bundle(handle_, &b); - ASSERT_EQ(ret, 0); bp = std::unique_ptr(b, bundle_free); + ASSERT_EQ(ret, 0); char* str; ret = bundle_get_str(bp.get(), "Test", &str); diff --git a/unit_tests/src/rpc_port_test.cc b/unit_tests/src/rpc_port_test.cc index 601f4c4..666dfed 100644 --- a/unit_tests/src/rpc_port_test.cc +++ b/unit_tests/src/rpc_port_test.cc @@ -105,10 +105,11 @@ class RpcPortConnection : public RpcPortBase { rpc_port_h port, void *data) -> int { RpcPortConnection* p = static_cast(data); p->stub_port_ = port; - rpc_port_stub_get_port(p->stub_handle_, RPC_PORT_PORT_CALLBACK, + int ret = rpc_port_stub_get_port(p->stub_handle_, RPC_PORT_PORT_CALLBACK, instance, &p->stub_callback_port_); - p->Finish(); + if (ret != 0) + return -1; return 0; }, this); ASSERT_EQ(ret, 0); -- 2.7.4 From e45e07405b14e33b3d65a743e7e4f7f1865a4042 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 11 Feb 2019 18:38:07 +0900 Subject: [PATCH 08/16] Release version 1.3.6 Changes: - Fix static analysis issues Change-Id: I7e18d80851248de0d62e30d35aedc2a368d01eca 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 675e137..d39e382 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.5 +Version: 1.3.6 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From c2396a11234b29967c735d893b8ef6c8c69e9ca2 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Feb 2019 09:40:05 +0900 Subject: [PATCH 09/16] Make weak dependencies - Uses "Recommends" instead of "Requires" Change-Id: Icd0fae74bd7ca931e606a4b87b930a5e1d24b2cf 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 d39e382..8239504 100755 --- a/packaging/rpc-port.spec +++ b/packaging/rpc-port.spec @@ -22,7 +22,7 @@ Requires(post): /sbin/ldconfig Requires(post): coreutils Requires(postun): /sbin/ldconfig -Requires: amd-mod-rpc-port +Recommends: amd-mod-rpc-port %description RPC Port library package. -- 2.7.4 From 0d231cf7f34efdd5f9599dc2f38e8277088451fe Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Feb 2019 13:34:01 +0900 Subject: [PATCH 10/16] Release version 1.3.7 Changes: - Make weak dependencies Change-Id: Id9456467e4fee049dcaff35c228c252fdbbf611f 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 8239504..2d756d5 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.6 +Version: 1.3.7 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From a344342db783c78f184a050b4aa75d938a0e122b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 15 Mar 2019 20:02:24 +0900 Subject: [PATCH 11/16] Fix fd leak Change-Id: I0a405972403b36cfb90e66ff73b2f36746c9a672 Signed-off-by: Hwankyu Jhun --- src/stub-internal.cc | 18 +++++++++++++++--- src/stub-internal.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/stub-internal.cc b/src/stub-internal.cc index 696eb6b..d6c85a0 100644 --- a/src/stub-internal.cc +++ b/src/stub-internal.cc @@ -81,6 +81,18 @@ std::shared_ptr Stub::FindDelegatePort( return {}; } +void Stub::RemoveAcceptedPorts(std::string instance) { + auto iter = ports_.begin(); + while (iter != ports_.end()) { + if ((*iter)->GetInstance().compare(instance) == 0) { + LOGI("Close: fd(%d)", (*iter)->GetFd()); + iter = ports_.erase(iter); + } else { + iter++; + } + } +} + gboolean Stub::OnDataReceived(GIOChannel *gio, GIOCondition cond, gpointer data) { Stub* stub = static_cast(data); @@ -92,7 +104,7 @@ gboolean Stub::OnDataReceived(GIOChannel *gio, GIOCondition cond, if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) { LOGW("Socket was disconnected from proxy. fd(%d)", fd); stub->listener_->OnDisconnected(p->GetId(), p->GetInstance()); - stub->ports_.remove(p); + stub->RemoveAcceptedPorts(p->GetInstance()); if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK) LOGW("Failed to notify rpc finished"); @@ -106,7 +118,7 @@ gboolean Stub::OnDataReceived(GIOChannel *gio, GIOCondition cond, if (ret != 0) { LOGW("Invalid protocol"); stub->listener_->OnDisconnected(p->GetId(), p->GetInstance()); - stub->ports_.remove(p); + stub->RemoveAcceptedPorts(p->GetInstance()); if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK) LOGW("Failed to notify rpc finished"); @@ -134,7 +146,7 @@ gboolean Stub::OnSocketDisconnected(GIOChannel *gio, GIOCondition cond, if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK) LOGW("Failed to notify rpc finished"); } - stub->ports_.remove(p); + stub->RemoveAcceptedPorts(p->GetInstance()); break; } } diff --git a/src/stub-internal.h b/src/stub-internal.h index e3408f2..cff2e7b 100644 --- a/src/stub-internal.h +++ b/src/stub-internal.h @@ -81,6 +81,7 @@ class Stub : private FdBroker::IEventListener { gpointer data); void OnFdReceived(const std::string& sender, int fds[2]) override; + void RemoveAcceptedPorts(std::string instance); private: std::list> ports_; -- 2.7.4 From d0fe260e81e9ca7dcb544bec906a3b95cf5f6a31 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 18 Mar 2019 13:05:37 +0900 Subject: [PATCH 12/16] Release version 1.3.8 Changes: - Fix fd leak Change-Id: I38021f218b636c3ed911fedd361dff48bd649601 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 2d756d5..762f3b5 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.7 +Version: 1.3.8 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From bda39552b64f688e669f60d2717a985b34c039d8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 21 Mar 2019 17:05:10 +0900 Subject: [PATCH 13/16] Check file descriptor Change-Id: Ib85fc88e9ea048db18ab2992f3c528ebdfc6ad3d Signed-off-by: Hwankyu Jhun --- src/port-internal.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/port-internal.cc b/src/port-internal.cc index daa11ce..264fa16 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -68,6 +68,11 @@ int Port::Read(void* buf, unsigned int size) { int max_timeout = MAX_CNT * MAX_SLEEP; /* 10 sec */ std::lock_guard lock(mutex_); + if (fd_ < 0 || fd_ >= sysconf(_SC_OPEN_MAX)) { + LOGE("Invalid fd(%d)", fd_); + return RPC_PORT_ERROR_IO_ERROR; + } + while (left) { nb = read(fd_, buffer, left); if (nb == 0) { @@ -114,6 +119,11 @@ int Port::Write(const void* buf, unsigned int size) { struct timespec end_time = { 0, }; std::lock_guard lock(mutex_); + if (fd_ < 0 || fd_ >= sysconf(_SC_OPEN_MAX)) { + LOGE("Invalid fd(%d)", fd_); + return RPC_PORT_ERROR_IO_ERROR; + } + fds[0].fd = fd_; fds[0].events = POLLOUT; fds[0].revents = 0; -- 2.7.4 From f7adaf8d4d5eca7a53ba89124d571c6cb6e30e49 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 22 Mar 2019 11:10:57 +0900 Subject: [PATCH 14/16] Release version 1.3.9 Changes: - Check file descriptor Change-Id: I81c2e120f36d707626a4737facecb067b3685f1d 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 762f3b5..10b7806 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.8 +Version: 1.3.9 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4 From 4b891b7a243af66cc85a9eac7642619ef1682891 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 27 May 2019 07:20:45 +0900 Subject: [PATCH 15/16] Fix OnSocketDisconnected event handling To call the OnDisconnectedEvent callback function, checking the type of the socket is removed. Change-Id: I2c08a08068960cc5217128ed738c8ccec6785b8c Signed-off-by: Hwankyu Jhun --- src/stub-internal.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/stub-internal.cc b/src/stub-internal.cc index d6c85a0..2630364 100644 --- a/src/stub-internal.cc +++ b/src/stub-internal.cc @@ -141,11 +141,9 @@ gboolean Stub::OnSocketDisconnected(GIOChannel *gio, GIOCondition cond, LOGW("Socket was disconnected. fd(%d)", fd); for (auto& p : stub->ports_) { if (p->GetFd() == fd) { - if (!p->IsDelegate()) { - stub->listener_->OnDisconnected(p->GetId(), p->GetInstance()); - if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK) - LOGW("Failed to notify rpc finished"); - } + stub->listener_->OnDisconnected(p->GetId(), p->GetInstance()); + if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK) + LOGW("Failed to notify rpc finished"); stub->RemoveAcceptedPorts(p->GetInstance()); break; } -- 2.7.4 From bfdd22603edabffa9eeef792e021bbf4db34a6d6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 27 May 2019 09:04:40 +0900 Subject: [PATCH 16/16] Release version 1.3.10 Changes: - Fix OnSocketDisconnected event handling Change-Id: I2a03f5a0c955e349c72bdb0321359f0d22382ff5 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 10b7806..ee56dd0 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.9 +Version: 1.3.10 Release: 0 Group: Application Framework/Libraries License: Apache-2.0 -- 2.7.4