提交 47c06ee2 编写于 作者: X xiacong

<fix>

修复seccomp测试用例概率失败的问题

<body>
由于前面的测试用例在结束后,仍有部分线程在运行,该运行的线程获取全局变量的读锁,在释放之前,本测试用例进行了fork,将该全局锁状态复制到了子进程,子进程又去获取该全局写锁,导致等不到读锁的释放,以致于子进程一直等待。
故在fork子进程前进行睡眠,等待其它线程释放读锁。
Signed-off-by: Nxiacong <xiacong4@huawei.com>
Change-Id: I324aa89bf8f0581d898b144e3db7a026e37df972
Signed-off-by: Nxiacong <xiacong4@huawei.com>
上级 ea20e0d4
......@@ -35,6 +35,7 @@
#include "seccomp_policy.h"
using SyscallFunc = bool (*)(void);
constexpr int SLEEP_TIME = 100000; // 100ms
using namespace testing::ext;
using namespace std;
......@@ -93,6 +94,11 @@ public:
std::cout << "signal failed:" << strerror(errno) << std::endl;
}
/* Sleeping for avoiding influencing child proccess wait for other threads
* which were created by other unittests to release global rwlock. The global
* rwlock will be used by function dlopen in child process */
usleep(SLEEP_TIME);
pid = StartChild(filterName, func);
if (pid == -1) {
std::cout << "fork failed:" << strerror(errno) << std::endl;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册