{ PadCmd::RestartLoader,
std::bind(&Launchpad::HandleRestartLoaderRequest, this,
std::placeholders::_1) },
+ { PadCmd::DisposeLoader,
+ std::bind(&Launchpad::HandleDisposeLoaderRequest, this,
+ std::placeholders::_1) },
};
CPUBoostController::Level level;
void Launchpad::HandleVisibilityRequest(std::shared_ptr<Request> request) {
LoaderManager::GetInst().ActivateLoaderContexts(LoaderMethod::Visibility);
request->SendResult(0);
- _D("[PAD_CMD_VISIBILITY]");
+ _W("[PAD_CMD_VISIBILITY]");
}
void Launchpad::HandleAddLoaderRequest(std::shared_ptr<Request> request) {
}
request->SendResult(context->GetLoaderId());
- _D("[PAD_CMD_ADD_LOADER]");
+ _W("[PAD_CMD_ADD_LOADER]");
}
void Launchpad::HandleRemoveLoaderRequest(std::shared_ptr<Request> request) {
LoaderManager::GetInst().RemoveLoaderContext(LoaderType::Dynamic,
std::stoi(loader_id_str));
request->SendResult(0);
- _D("[PAD_CMD_REMOVE_LOADER]");
+ _W("[PAD_CMD_REMOVE_LOADER]");
}
void Launchpad::HandleMakeDefaultSlotsRequest(
std::shared_ptr<Request> request) {
LoaderManager::GetInst().AddDefaultLoaderContexts();
- _D("[PAD_CMD_MAKE_DEFAULT_SLOTS]");
+ _W("[PAD_CMD_MAKE_DEFAULT_SLOTS]");
}
void Launchpad::HandlePrepareAppDefinedLoaderRequest(
}
request->SendResult(context->GetLoaderId());
- _D("[PAD_CMD_PREPARE_APP_DEFINED_LOADER] result: %d", context->GetLoaderId());
+ _W("[PAD_CMD_PREPARE_APP_DEFINED_LOADER] result: %d", context->GetLoaderId());
}
void Launchpad::HandleDemandRequest(std::shared_ptr<Request> request) {
LoaderManager::GetInst().ActivateLoaderContexts(LoaderMethod::Demand);
request->SendResult(0);
- _D("[PAD_CMD_DEMAND]");
+ _W("[PAD_CMD_DEMAND]");
}
void Launchpad::HandlePingRequest(std::shared_ptr<Request> request) {
request->SendResult(getpid());
- _D("[PAD_CMD_PING]");
+ _W("[PAD_CMD_PING]");
}
void Launchpad::HandleUpdateAppTypeRequest(std::shared_ptr<Request> request) {
_I("type: %s, installed: %s", app_type.c_str(), installed.c_str());
bool app_installed = (installed == "true") ? true : false;
LoaderManager::GetInst().UpdateAppInstallationStatus(app_type, app_installed);
- _D("[PAD_CMD_UPDATE_APP_TYPE]");
+ _W("[PAD_CMD_UPDATE_APP_TYPE]");
}
void Launchpad::HandleConnectRequest(std::shared_ptr<Request> request) {
client_socket_.reset(
new ClientSocket(request->GetClientSocket()->RemoveFd()));
- _D("[PAD_CMD_CONNECT] client fd: %d", client_socket_->GetFd());
+ _W("[PAD_CMD_CONNECT] client fd: %d", client_socket_->GetFd());
}
bool Launchpad::CanUseLoaderContext(
CPUBoostController::DoBoost(loader_context->GetPid(),
CPUBoostController::Level::Strong, 10000);
_W("Send result: %d", loader_context->GetPid());
+ request->SetPid(loader_context->GetPid());
request->SendResult(loader_context->GetPid());
}
return;
LaunchRequestComplete(request);
- _D("[PAD_CMD_LAUNCH] appid: %s, result: %d",
+ _W("[PAD_CMD_LAUNCH] appid: %s, result: %d",
request->GetAppInfo()->GetAppId().c_str(), request->GetPid());
}
if (loader_context->RefCount() == 0)
loader_context->Dispose();
- _D("[PAD_CMD_KILL_LOADER] loader_name: %s", loader_name.c_str());
+ _W("[PAD_CMD_KILL_LOADER] loader_name: %s", loader_name.c_str());
}
void Launchpad::HandleRestartLoaderRequest(std::shared_ptr<Request> request) {
if (loader_context->GetPid() < 1)
loader_context->Prepare();
- _D("[PAD_CMD_RESTART_LOADER] loader_name: %s, pid: %d",
+ _W("[PAD_CMD_RESTART_LOADER] loader_name: %s, pid: %d",
loader_name.c_str(), loader_context->GetPid());
}
+void Launchpad::HandleDisposeLoaderRequest(std::shared_ptr<Request> request) {
+ pid_t caller_pid = request->GetCallerPid();
+ auto loader_context =
+ LoaderManager::GetInst().FindLoaderContextFromPid(caller_pid);
+ if (loader_context == nullptr) {
+ _E("Failed to find loader context. pid(%d)", caller_pid);
+ return;
+ }
+
+ loader_context->Dispose();
+ _W("[PAD_CMD_DISPOSE_LOADER] loader_name: %s, pid: %d",
+ loader_context->GetLoaderName().c_str(), caller_pid);
+}
+
void Launchpad::OnIOEventReceived(int fd, int condition) {
auto client_socket = socket_->Accept();
if (!client_socket) {
while (iter != pending_requests_.end()) {
auto request = *iter;
auto context = request->GetAvailableLoaderContext();
- if (context != nullptr && context->GetPid() == pid) {
+ if (context != nullptr && request->GetPid() == pid) {
context->Unref();
auto* app_info = request->GetAppInfo();
- launchpad::DBus::SendAppLaunchSignal(context->GetPid(),
+ launchpad::DBus::SendAppLaunchSignal(request->GetPid(),
app_info->GetAppId().c_str());
pending_requests_.erase(iter);
break;
#include "launchpad/launchpad_loader.hh"
#include <aul.h>
+#include <aul_sock.h>
#include <bundle_cpp.h>
#include <malloc.h>
#include <sys/types.h>
const uint32_t kMaxRetryingCount = 600;
constexpr const char kLaunchpadLoaderSocketName[] = ".launchpad-type";
+constexpr const char kLaunchpadProcessPoolSock[] =
+ ".launchpad-process-pool-sock";
tizen_base::Bundle loader_bundle;
LaunchpadLoader* context = nullptr;
return app_info_.GetBundle();
}
+void LaunchpadLoader::SendDisposalRequest() {
+ int fd = aul_sock_create_launchpad_client(kLaunchpadProcessPoolSock,
+ getuid());
+ if (fd < 0) {
+ _E("Failed to create launchpad client socket. error(%d)", fd);
+ return;
+ }
+
+ tizen_base::Bundle b;
+ int ret = aul_sock_send_bundle_with_fd(fd,
+ static_cast<int>(PadCmd::DisposeLoader), b.GetHandle(), AUL_SOCK_NOREPLY);
+ if (ret != AUL_R_OK)
+ _E("Failed to send disposal request. error(%d)", ret);
+}
+
void LaunchpadLoader::ResetArgs() {
memset(argv_[LoaderArg::Type], 0, strlen(argv_[LoaderArg::Type]));
memset(argv_[LoaderArg::Id], 0, strlen(argv_[LoaderArg::Id]));
extern "C" EXPORT_API int launchpad_loader_unblock_threads(void) {
return ThreadControl::GetInst().UnblockThreads();
}
+
+extern "C" EXPORT_API void launchpad_loader_dispose(void) {
+ if (!::context) {
+ _E("Invalid context");
+ return;
+ }
+
+ _W("Dispose");
+ ::context->SendDisposalRequest();
+}