Skip to content

Commit b656429

Browse files
authored
dev: try again to open lock file (#445) (#446)
open an existing file with O_CREAT can fail Signed-off-by: Ric Li <[email protected]>
1 parent e360533 commit b656429

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/src/mt_dev.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,13 @@ int dev_reset_port(struct mtl_main_impl* impl, enum mtl_port port) {
12341234

12351235
static int dev_filelock_lock(struct mtl_main_impl* impl) {
12361236
int fd = open(MT_FLOCK_PATH, O_RDONLY | O_CREAT, 0666);
1237-
12381237
if (fd < 0) {
1239-
err("%s, failed to open %s, %s\n", __func__, MT_FLOCK_PATH, strerror(errno));
1240-
return -EIO;
1238+
/* sometimes may fail due to user permission, try open read-only */
1239+
fd = open(MT_FLOCK_PATH, O_RDONLY);
1240+
if (fd < 0) {
1241+
err("%s, failed to open %s, %s\n", __func__, MT_FLOCK_PATH, strerror(errno));
1242+
return -EIO;
1243+
}
12411244
}
12421245
impl->lcore_lock_fd = fd;
12431246
/* wait until locked */

0 commit comments

Comments
 (0)