diff options
author | SukhyungKang <shine.kang@samsung.com> | 2023-08-01 10:26:32 +0900 |
---|---|---|
committer | SukhyungKang <shine.kang@samsung.com> | 2023-08-01 10:26:32 +0900 |
commit | c60592609df0142532fd59223f01996dcab87f46 (patch) | |
tree | 2be3f3aca82d7e1256e3b0992931f47b7a7771de | |
parent | 5385cba85ae004bc51415e5a9fc946e5167bd00d (diff) | |
download | notification-c60592609df0142532fd59223f01996dcab87f46.tar.gz notification-c60592609df0142532fd59223f01996dcab87f46.tar.bz2 notification-c60592609df0142532fd59223f01996dcab87f46.zip |
fix socket fd double close
Change-Id: I8d683e7570f9de8472a4adaa77ea2b9f2fb9818a
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
-rw-r--r-- | notification-ex/dbus_event_listener.cc | 4 | ||||
-rw-r--r-- | notification-ex/ex_util.cc | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/notification-ex/dbus_event_listener.cc b/notification-ex/dbus_event_listener.cc index ebea9b6..b61568a 100644 --- a/notification-ex/dbus_event_listener.cc +++ b/notification-ex/dbus_event_listener.cc @@ -230,7 +230,9 @@ list<Bundle> DBusEventListener::Impl::ReadNotiList( LOGE("Fail to get socket fd"); return ret_list; } - ret_list = util::ReadBundleList(recvfd, noti_cnt); + SocketHandler recv_sock(recvfd); + + ret_list = util::ReadBundleList(recv_sock.Get(), noti_cnt); return ret_list; } diff --git a/notification-ex/ex_util.cc b/notification-ex/ex_util.cc index d961c5b..19943ca 100644 --- a/notification-ex/ex_util.cc +++ b/notification-ex/ex_util.cc @@ -234,14 +234,14 @@ unsigned int ReadSocket(int fd, char* buffer, unsigned int nbytes) { list<tizen_base::Bundle> ReadBundleList(int recvfd, int noti_cnt) { list<tizen_base::Bundle> ret_list; list<tizen_base::Bundle> empty_list; - SocketHandler recv_sock(recvfd); unsigned int buf_size = 0; unsigned int data_size = 0; - buf_size = util::GetSocketBufferSize(recv_sock.Get(), SO_RCVBUF); + + buf_size = util::GetSocketBufferSize(recvfd, SO_RCVBUF); std::unique_ptr<char, decltype(std::free)*> data_ptr( static_cast<char*>(calloc(buf_size, sizeof(char))), std::free); for (int i = 0; i < noti_cnt; i++) { - int ret = util::ReadSocket(recv_sock.Get(), + int ret = util::ReadSocket(recvfd, reinterpret_cast<char*>(&data_size), sizeof(data_size)); if (ret != 0) return empty_list; @@ -250,7 +250,7 @@ list<tizen_base::Bundle> ReadBundleList(int recvfd, int noti_cnt) { data_ptr.reset(static_cast<char*>(calloc(buf_size, sizeof(char)))); } memset(data_ptr.get(), 0, buf_size); - ret = util::ReadSocket(recv_sock.Get(), data_ptr.get(), data_size); + ret = util::ReadSocket(recvfd, data_ptr.get(), data_size); if (ret != 0) return empty_list; ret_list.emplace_back(data_ptr.get()); |