#include <amd_mod_common.h>
#include <aul.h>
#include <aul_cmd.h>
+#include <aul_proc.h>
#include <aul_rpc_port.h>
#include <aul_sock.h>
#include <aul_svc.h>
uid_t target_uid = amd_request_get_target_uid(req);
auto& inst = PortManager::GetInst();
+ inst.RemovePort(port_name, pid);
+ auto* port = inst.FindPort(app_id, port_name, target_uid);
+ if (port != nullptr) {
+ char buf[PATH_MAX] = { 0, };
+ int ret = aul_proc_get_cmdline(port->GetPid(), buf, sizeof(buf));
+ if (ret == AUL_R_OK) {
+ _E("Already exists. app_id(%s), port_name(%s), pid(%d)",
+ app_id, port_name, port->GetPid());
+ amd_request_send_result(req, -1);
+ return -1;
+ }
+
+ _E("Process(%d) is not running", port->GetPid());
+ inst.RemovePort(port_name, port->GetPid());
+ }
+
int ret = inst.AddPort(app_id, port_name, pid, target_uid);
if (ret < 0) {
_E("Failed to add port. pid(%d), port_name(%s)", pid, port_name);
#include <amd.h>
#include <aul.h>
-#include <aul_proc.h>
#include <aul_rpc_port.h>
#include <bundle_cpp.h>
if (port == nullptr)
return false;
- char buf[PATH_MAX] = { 0, };
- int ret = aul_proc_get_cmdline(port->GetPid(), buf, sizeof(buf));
- if (ret != AUL_R_OK) {
- RemovePort(port->GetPortName(), port->GetPid());
- return false;
- }
-
return true;
}
int PortManager::AddPort(const std::string& app_id,
const std::string& port_name, pid_t pid, uid_t uid) {
- if (ExistPort(app_id, port_name, uid)) {
- _E("Already exists. app_id(%s), port_name(%s), uid(%u)",
- app_id.c_str(), port_name.c_str(), uid);
- return -EALREADY;
- }
-
auto* port = PortInfo::Create(app_id, port_name, pid, uid);
if (port == nullptr)
return -1;