51 lines
1.2 KiB
Diff
51 lines
1.2 KiB
Diff
|
|
From d59e4d224b3271cf7a7fe53cd7c5d539b58eac32 Mon Sep 17 00:00:00 2001
|
||
|
|
From: lvying <lvying6@huawei.com>
|
||
|
|
Date: Sat, 26 Jan 2019 15:54:17 +0800
|
||
|
|
Subject: [PATCH] rasdaemon:fix rasdaemon wait for file access
|
||
|
|
|
||
|
|
reason:fix fix rasdaemon wait for file access
|
||
|
|
|
||
|
|
--- rasdaemon-0.4.1/ras-events.c 2018-04-08 04:05:18.755000000 -0400
|
||
|
|
+++ rasdaemon-0.4.1/ras-events.c 2018-04-08 04:05:46.879000000 -0400
|
||
|
|
@@ -89,15 +89,39 @@
|
||
|
|
return ENOENT;
|
||
|
|
}
|
||
|
|
|
||
|
|
+static int wait_access(char *path, int ms)
|
||
|
|
+{
|
||
|
|
+ int i;
|
||
|
|
+ for (i = 0; i < ms; i++) {
|
||
|
|
+ if (access(path, F_OK) == 0)
|
||
|
|
+ return 0;
|
||
|
|
+ usleep(1000);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ log(ALL, LOG_WARNING, "wait_access() failed, %s not created in %d ms\n", path, ms);
|
||
|
|
+ return -1;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static int open_trace(struct ras_events *ras, char *name, int flags)
|
||
|
|
{
|
||
|
|
+ int ret = 0;
|
||
|
|
char fname[MAX_PATH + 1];
|
||
|
|
|
||
|
|
strcpy(fname, ras->tracing);
|
||
|
|
strcat(fname, "/");
|
||
|
|
strcat(fname, name);
|
||
|
|
|
||
|
|
- return open(fname, flags);
|
||
|
|
+ ret = wait_access(fname, 100);
|
||
|
|
+ if (ret != 0) {
|
||
|
|
+ /* use -1 to keep same error value with open() */
|
||
|
|
+ return -1;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ ret = open(fname, flags);
|
||
|
|
+ if (ret == -1)
|
||
|
|
+ log(ALL, LOG_WARNING, "open_trace()->open() failed, fname=%s ret=%d errno=%d\n", fname, ret, errno);
|
||
|
|
+
|
||
|
|
+ return ret;
|
||
|
|
}
|
||
|
|
|
||
|
|
static int get_tracing_dir(struct ras_events *ras)
|