From: Hwankyu Jhun Date: Wed, 18 Jan 2023 06:20:02 +0000 (+0000) Subject: Modify Port::Write() method X-Git-Tag: accepted/tizen/7.0/unified/20230119.134109~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3103055ec62f1074ba1ffe5817ef7fd8abd72476;p=platform%2Fcore%2Fappfw%2Frpc-port.git Modify Port::Write() method After this patch is applied, if the cache buffer is not empty, the rpc-port library checks the socket whether writing is possible or not. If it's possible, the rpc-port library writes the delayed message to the socket fd. Change-Id: If54967bbc7fce4d4494b9fee44d8dcfe5e57de50 Signed-off-by: Hwankyu Jhun --- diff --git a/src/port-internal.cc b/src/port-internal.cc index b895d88..a937278 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -223,19 +223,7 @@ int Port::Write(const void* buf, unsigned int size) { return RPC_PORT_ERROR_NONE; else if (ret == PORT_STATUS_ERROR_IO_ERROR) return RPC_PORT_ERROR_IO_ERROR; - } - - if (delayed_message_size_ > QUEUE_SIZE_MAX) { - _E("cache fail : delayed_message_size (%d), count(%zu)", - delayed_message_size_, queue_.size()); - return RPC_PORT_ERROR_IO_ERROR; - } - - ret = PushDelayedMessage( - std::make_shared(static_cast(buf), - sent_bytes, size)); - - if (CanWrite()) { + } else if (CanWrite()) { while (!queue_.empty()) { int port_status = PopDelayedMessage(); if (port_status != PORT_STATUS_ERROR_NONE) { @@ -247,7 +235,15 @@ int Port::Write(const void* buf, unsigned int size) { } } - return ret; + if (delayed_message_size_ > QUEUE_SIZE_MAX) { + _E("cache fail : delayed_message_size (%d), count(%zu)", + delayed_message_size_, queue_.size()); + return RPC_PORT_ERROR_IO_ERROR; + } + + return PushDelayedMessage( + std::make_shared( + static_cast(buf), sent_bytes, size)); } int Port::Write(const void* buf, unsigned int size, int* sent_bytes) { @@ -299,6 +295,8 @@ gboolean Port::OnEventReceived(GIOChannel* io, GIOCondition condition, return G_SOURCE_REMOVE; } + _W("Writing is now possible. fd: %d, id: %s", + port->GetFd(), port->GetId().c_str()); std::lock_guard lock(port->rw_mutex_); if (port->source_id_ == 0) { _E("GSource is destroyed");