From: Hwankyu Jhun Date: Mon, 12 Aug 2024 21:55:06 +0000 (+0900) Subject: Modify implementation related to sync function X-Git-Tag: accepted/tizen/unified/20240814.180318~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b9834757c6bfd74d2498187f65eec55c06dc12d;p=platform%2Fcore%2Fappfw%2Frpc-port.git Modify implementation related to sync function - Change retrying count to 250. - Check whether the stub is system daemon or not - Fix a bug about delegate invocation Change-Id: I49b36eb990957dabaa29d462b74e6c32df501c93 Signed-off-by: Hwankyu Jhun --- diff --git a/src/rpc-port/aul-internal.cc b/src/rpc-port/aul-internal.cc index 628cd5f..ec32a6c 100644 --- a/src/rpc-port/aul-internal.cc +++ b/src/rpc-port/aul-internal.cc @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include @@ -27,6 +29,8 @@ namespace rpc_port { namespace internal { +const uid_t kRegularUidMin = 5000; + std::string Aul::GetName(int pid) { char* name = nullptr; if (aul_proc_get_name(pid, &name) != AUL_R_OK) return ""; @@ -36,16 +40,13 @@ std::string Aul::GetName(int pid) { } std::string Aul::GetAppId(int pid) { - char app_id[256] = { 0, }; - int ret = aul_app_get_appid_bypid(pid, app_id, sizeof(app_id)); - if (ret != AUL_R_OK) { - // LCOV_EXCL_START - _E("aul_app_get_appid_bypid() is failed. pid(%d), error(%d)", pid, ret); - return GetName(pid); - // LCOV_EXCL_STOP + if (getuid() >= kRegularUidMin) { + char app_id[256] = { 0, }; + int ret = aul_app_get_appid_bypid(pid, app_id, sizeof(app_id)); + if (ret == AUL_R_OK) return std::string(app_id); } - return std::string(app_id); + return GetName(pid); } std::string Aul::GetPortPath(const std::string& app_id, diff --git a/src/rpc-port/proxy-internal.cc b/src/rpc-port/proxy-internal.cc index 4e9b202..3734b7c 100644 --- a/src/rpc-port/proxy-internal.cc +++ b/src/rpc-port/proxy-internal.cc @@ -238,7 +238,7 @@ int Proxy::ConnectSync(std::string appid, std::string port_name, bool Proxy::WaitUntilPortCreation() { file_monitor_.reset(new FileMonitor(port_path_)); - int retry_count = rpc_port_get_timeout() / 1000; + int retry_count = rpc_port_get_timeout() / 100; do { if (file_monitor_->Exist()) return true; diff --git a/src/rpc-port/proxy-port-internal.cc b/src/rpc-port/proxy-port-internal.cc index 802693a..a93a0d8 100644 --- a/src/rpc-port/proxy-port-internal.cc +++ b/src/rpc-port/proxy-port-internal.cc @@ -30,7 +30,10 @@ ProxyPort::ProxyPort(int read_fd, int write_fd, std::string id, IEvent* listener, bool is_delegate) : Port(read_fd, write_fd, std::move(id)), listener_(listener), - is_delegate_(is_delegate) {} + is_delegate_(is_delegate) { + if (read_fd > -1) + Watch(read_fd); +} ProxyPort::~ProxyPort() { GLib::SourceDestroy(source_); } diff --git a/src/rpc-port/stub-internal.cc b/src/rpc-port/stub-internal.cc index d0e89d4..68864aa 100644 --- a/src/rpc-port/stub-internal.cc +++ b/src/rpc-port/stub-internal.cc @@ -150,8 +150,9 @@ void Stub::RemoveAcceptedPorts(std::string instance) { } int Stub::CreatePort() { - if (getenv("AUL_APPID") == nullptr) { - std::string name = Aul::GetName(getpid()); + const char* appid = getenv("AUL_APPID"); + if (getuid() < kRegularUidMin || appid == nullptr) { + std::string name = appid ? appid : Aul::GetName(getpid()); if (!name.empty()) { port_path_ = Aul::GetPortPath(name, GetPortName(), getuid()); int fd = GetFdFromSystemd(); @@ -301,7 +302,8 @@ std::recursive_mutex& Stub::GetMutex() const { void Stub::CheckPermission(const std::shared_ptr& request, const std::shared_ptr& client, const std::shared_ptr& cred) { - std::string app_id = Aul::GetAppId(cred->GetPid()); + std::string app_id; + if (cred->GetUid() >= kRegularUidMin) app_id = Aul::GetAppId(cred->GetPid()); auto response_func = [=](int res) -> void { if (freed_stubs_.find(this) != freed_stubs_.end()) return; // LCOV_EXCL_LINE