mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-27 01:31:10 +00:00
Fix connectserver and inspector initialization
Issue: IAS6Z2 Signed-off-by: bigtea <tianqushen@huawei.com>
This commit is contained in:
parent
4c43ee004b
commit
1d1fc828f2
@ -174,12 +174,16 @@ void ResetService()
|
||||
}
|
||||
}
|
||||
|
||||
void StartServerForSocketPair(int socketfd)
|
||||
bool StartServerForSocketPair(int socketfd)
|
||||
{
|
||||
LOGI("StartServerForSocketPair, socketfd = %{private}d", socketfd);
|
||||
if (g_inspector == nullptr) {
|
||||
g_inspector = std::make_unique<ConnectInspector>();
|
||||
}
|
||||
if (g_inspector->connectServer_ != nullptr) {
|
||||
LOGW("ConnectServer is not nullptr!");
|
||||
return false;
|
||||
}
|
||||
g_inspector->connectServer_ = std::make_unique<ConnectServer>(socketfd,
|
||||
std::bind(&OnMessage, std::placeholders::_1));
|
||||
|
||||
@ -188,8 +192,9 @@ void StartServerForSocketPair(int socketfd)
|
||||
static_cast<void*>(g_inspector->connectServer_.get())) != 0) {
|
||||
LOGE("pthread_create fail!");
|
||||
ResetService();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void StartServer(const std::string& componentName)
|
||||
|
@ -32,7 +32,7 @@ extern "C" {
|
||||
void StartServer(const std::string& componentName);
|
||||
|
||||
// socketpair process.
|
||||
void StartServerForSocketPair(int socketfd);
|
||||
bool StartServerForSocketPair(int socketfd);
|
||||
|
||||
void StopServer([[maybe_unused]] const std::string& componentName);
|
||||
|
||||
|
@ -150,18 +150,15 @@ bool InitializeInspector(
|
||||
void* vm, const DebuggerPostTask& debuggerPostTask, const DebugInfo& debugInfo, int tidForSocketPair = 0)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(g_mutex);
|
||||
Inspector *newInspector = nullptr;
|
||||
auto iter = g_inspectors.find(vm);
|
||||
if (iter != g_inspectors.end()) {
|
||||
newInspector = g_inspectors[vm];
|
||||
} else {
|
||||
newInspector = new Inspector();
|
||||
if (!g_inspectors.emplace(vm, newInspector).second) {
|
||||
delete newInspector;
|
||||
return false;
|
||||
}
|
||||
LOGW("Inspector already exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Inspector *newInspector = new Inspector();
|
||||
g_inspectors.emplace(vm, newInspector);
|
||||
|
||||
newInspector->tidForSocketPair_ = tidForSocketPair;
|
||||
newInspector->tid_ = pthread_self();
|
||||
newInspector->vm_ = vm;
|
||||
|
@ -131,7 +131,9 @@ HWTEST_F(ConnectServerTest, InspectorConnectTest, testing::ext::TestSize.Level0)
|
||||
#if defined(OHOS_PLATFORM)
|
||||
int appPid = getprocpid();
|
||||
int oldProcessfd = -2;
|
||||
StartServerForSocketPair(oldProcessfd);
|
||||
ASSERT_TRUE(StartServerForSocketPair(oldProcessfd));
|
||||
// test ConnectServer is not nullptr
|
||||
ASSERT_FALSE(StartServerForSocketPair(oldProcessfd));
|
||||
StoreMessage(g_instanceId, HELLO_INSPECTOR_CLIENT);
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user