diff options
| author | ruki <[email protected]> | 2019-07-27 00:06:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-07-26 18:37:32 +0800 |
| commit | 7b14cb81d62177aea37e56ccdb3d0f91ec8d8f29 (patch) | |
| tree | 0beae22fba4a5cc1810a710e6bb96dc989ad5b52 /core/src | |
| parent | 8f13f68c5b41744f5f420aaf89d282283c33ac5b (diff) | |
improve filelock
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/io/openlock.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/src/xmake/io/openlock.c b/core/src/xmake/io/openlock.c index c3653cbfc..42d905557 100644 --- a/core/src/xmake/io/openlock.c +++ b/core/src/xmake/io/openlock.c @@ -47,7 +47,10 @@ tb_int_t xm_io_openlock(lua_State* lua) tb_assert_and_check_return_val(path, 0); // init file lock - tb_filelock_ref_t lock = tb_filelock_init_from_path(path, tb_file_info(path, tb_null)? TB_FILE_MODE_RO : TB_FILE_MODE_RW | TB_FILE_MODE_CREAT); + tb_long_t tryn = 2; + tb_filelock_ref_t lock = tb_null; + while (!lock && tryn-- > 0) + lock = tb_filelock_init_from_path(path, tb_file_info(path, tb_null)? TB_FILE_MODE_RO : TB_FILE_MODE_RW | TB_FILE_MODE_CREAT); if (lock) { // init file lock |
