Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The rasdaemon service may fail to be started for the first time. #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
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)
{
char fname[MAX_PATH + 1];
Expand All @@ -113,6 +126,12 @@ static int open_trace(struct ras_events *ras, char *name, int flags)
if (rc < 0)
return rc;

rc = wait_access(fname, 30000);
if (rc != 0) {
/* use -1 to keep same error value with open() */
return -1;
}

rc = open(fname, flags);
if (rc < 0) {
rc = -errno;
Expand Down