加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0032-Pin-server-Bugfix-for-the-operation-sequence-of-user.patch 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
MC.5 提交于 2024-04-08 21:25 . [sync] Sync patch from openEuler/pin-server
From b239a7940f1439d425cb37729fe380db73734856 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=99=A8=E5=8D=89?= <zhengchenhui1@huawei.com>
Date: Fri, 3 Nov 2023 11:39:12 +0800
Subject: [PATCH 5/7] [Pin-server] Bugfix for the operation sequence of
userOpts.
---
lib/PluginServer/PluginServer.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/PluginServer/PluginServer.cpp b/lib/PluginServer/PluginServer.cpp
index 8778019..9a8d5e5 100644
--- a/lib/PluginServer/PluginServer.cpp
+++ b/lib/PluginServer/PluginServer.cpp
@@ -23,6 +23,7 @@
#include <thread>
#include <fcntl.h>
#include <sys/stat.h>
+#include <mutex>
#include "PluginAPI/PluginServerAPI.h"
#include "user/user.h"
@@ -34,6 +35,8 @@ using namespace PluginOpt;
using std::cout;
using std::endl;
using std::pair;
+
+static std::mutex register_mutex; // 线程锁
PluginServer *PluginServer::pluginServerPtr = nullptr;
PluginServer *PluginServer::GetInstance()
{
@@ -273,6 +276,7 @@ void PluginServer::ParseArgv(const string& data)
void PluginServer::SendRegisteredUserOpts()
{
+ register_mutex.lock();
for (auto it = userOpts.begin(); it != userOpts.end(); it++) {
string key = "injectPoint";
for (auto& userOpt : it->second) {
@@ -286,6 +290,7 @@ void PluginServer::SendRegisteredUserOpts()
}
}
pluginCom.ServerSend("injectPoint", "finished");
+ register_mutex.unlock();
}
void PluginServer::ServerSemPost(const string& port)
@@ -307,8 +312,9 @@ void PluginServer::RunServer()
}
log->LOGI("Server ppid:%d listening on port:%s\n", getppid(), port.c_str());
ServerSemPost(port);
-
+ register_mutex.lock();
RegisterCallbacks();
+ register_mutex.unlock();
log->LOGI("RunServer: RegisterCallbacks Done.\n");
pluginCom.Run();
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化