Better error message.
GitOrigin-RevId: 90f177a01b941a8fe029fb6363858260a0ca1f3b
This commit is contained in:
parent
fa99ec2875
commit
36562f351c
@ -345,7 +345,7 @@ Status FileFd::lock(FileFd::LockFlags flags, int32 max_tries) {
|
|||||||
|
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
if (fcntl(get_native_fd(), F_SETLK, &lock) == -1) {
|
if (fcntl(get_native_fd(), F_SETLK, &lock) == -1) {
|
||||||
if (errno == EAGAIN && --max_tries > 0) {
|
if (errno == EAGAIN) {
|
||||||
#elif TD_PORT_WINDOWS
|
#elif TD_PORT_WINDOWS
|
||||||
OVERLAPPED overlapped;
|
OVERLAPPED overlapped;
|
||||||
std::memset(&overlapped, 0, sizeof(overlapped));
|
std::memset(&overlapped, 0, sizeof(overlapped));
|
||||||
@ -363,12 +363,16 @@ Status FileFd::lock(FileFd::LockFlags flags, int32 max_tries) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (GetLastError() == ERROR_LOCK_VIOLATION && --max_tries > 0) {
|
if (GetLastError() == ERROR_LOCK_VIOLATION) {
|
||||||
#endif
|
#endif
|
||||||
|
if (--max_tries > 0) {
|
||||||
usleep_for(100000);
|
usleep_for(100000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return OS_ERROR("Can't lock file because it is already in use; check for another program instance running");
|
||||||
|
}
|
||||||
|
|
||||||
return OS_ERROR("Can't lock file");
|
return OS_ERROR("Can't lock file");
|
||||||
}
|
}
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
|
Reference in New Issue
Block a user