The change in patches: 1. Fix cache issue when recreate file 2. Introduce CMAKE to build userspace apps 3. CleanCode Signed-off-by: Weifeng Su <suweifeng1@huawei.com>
55 lines
1.4 KiB
Diff
55 lines
1.4 KiB
Diff
From a79ba9896c37d30cd1901f7f54e0507adb9aabda Mon Sep 17 00:00:00 2001
|
|
From: liqiang <liqiang64@huawei.com>
|
|
Date: Mon, 12 Jun 2023 11:34:09 +0800
|
|
Subject: engine running lock
|
|
|
|
Signed-off-by: liqiang <liqiang64@huawei.com>
|
|
---
|
|
qtfs/qtfs_common/user_engine.c | 16 +++++++++++++++-
|
|
1 file changed, 15 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/qtfs/qtfs_common/user_engine.c b/qtfs/qtfs_common/user_engine.c
|
|
index 919da11..7455413 100644
|
|
--- a/qtfs/qtfs_common/user_engine.c
|
|
+++ b/qtfs/qtfs_common/user_engine.c
|
|
@@ -33,7 +33,7 @@
|
|
#include <errno.h>
|
|
#include <sys/resource.h>
|
|
#include <sys/prctl.h>
|
|
-
|
|
+#include <sys/file.h>
|
|
#include <sys/epoll.h>
|
|
|
|
#include "comm.h"
|
|
@@ -68,6 +68,16 @@ struct engine_arg {
|
|
|
|
#define QTFS_USERP_SIZE QTFS_USERP_MAXSIZE
|
|
#define QTFS_SERVER_FILE "/dev/qtfs_server"
|
|
+#define ENGINE_LOCK_ADDR "/var/run/qtfs/engine.lock"
|
|
+
|
|
+int engine_socket_lock(void)
|
|
+{
|
|
+ int lock_fd = open(ENGINE_LOCK_ADDR, O_RDONLY | O_CREAT, 0600);
|
|
+ if (lock_fd == -1)
|
|
+ return -EINVAL;
|
|
+
|
|
+ return flock(lock_fd, LOCK_EX | LOCK_NB);
|
|
+}
|
|
|
|
int qtfs_fd;
|
|
int engine_run = 1;
|
|
@@ -365,6 +375,10 @@ int main(int argc, char *argv[])
|
|
engine_out(" Example: %s 16 1 192.168.10.10 12121 192.168.10.11 12121.", argv[0]);
|
|
return -1;
|
|
}
|
|
+ if (engine_socket_lock() < 0) {
|
|
+ engine_err("Engine is running.");
|
|
+ return -1;
|
|
+ }
|
|
if (qtfs_engine_env_check(argv) < 0) {
|
|
engine_err("Environment check failed, engine exit.");
|
|
return -1;
|
|
--
|
|
2.33.0
|
|
|