Skip to content

Commit

Permalink
dev: try again to open lock file (#445) (#446)
Browse files Browse the repository at this point in the history
open an existing file with O_CREAT can fail

Signed-off-by: Ric Li <ming3.li@intel.com>
  • Loading branch information
ricmli authored Aug 22, 2023
1 parent e360533 commit b656429
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/src/mt_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,13 @@ int dev_reset_port(struct mtl_main_impl* impl, enum mtl_port port) {

static int dev_filelock_lock(struct mtl_main_impl* impl) {
int fd = open(MT_FLOCK_PATH, O_RDONLY | O_CREAT, 0666);

if (fd < 0) {
err("%s, failed to open %s, %s\n", __func__, MT_FLOCK_PATH, strerror(errno));
return -EIO;
/* sometimes may fail due to user permission, try open read-only */
fd = open(MT_FLOCK_PATH, O_RDONLY);
if (fd < 0) {
err("%s, failed to open %s, %s\n", __func__, MT_FLOCK_PATH, strerror(errno));
return -EIO;
}
}
impl->lcore_lock_fd = fd;
/* wait until locked */
Expand Down

0 comments on commit b656429

Please sign in to comment.