mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Do not invoke usleep() for more than 999999 microseconds.
FossilOrigin-Name: 1f5ed852f25515bbc0a7aaf236fdef40fa7e31805eee1249277fde4e68f95130
This commit is contained in:
@@ -1545,6 +1545,9 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Forward declaration*/
|
||||
static int unixSleep(sqlite3_vfs*,int);
|
||||
|
||||
/*
|
||||
** Set a posix-advisory-lock.
|
||||
**
|
||||
@@ -1574,7 +1577,7 @@ static int osSetPosixAdvisoryLock(
|
||||
** generic posix, however, there is no such API. So we simply try the
|
||||
** lock once every millisecond until either the timeout expires, or until
|
||||
** the lock is obtained. */
|
||||
usleep(1000);
|
||||
unixSleep(0,1000);
|
||||
rc = osFcntl(h,F_SETLK,pLock);
|
||||
tm--;
|
||||
}
|
||||
@@ -6576,7 +6579,8 @@ static int unixSleep(sqlite3_vfs *NotUsed, int microseconds){
|
||||
UNUSED_PARAMETER(NotUsed);
|
||||
return microseconds;
|
||||
#elif defined(HAVE_USLEEP) && HAVE_USLEEP
|
||||
usleep(microseconds);
|
||||
if( microseconds>=1000000 ) sleep(microseconds/1000000);
|
||||
if( microseconds%1000000 ) usleep(microseconds%1000000);
|
||||
UNUSED_PARAMETER(NotUsed);
|
||||
return microseconds;
|
||||
#else
|
||||
@@ -7149,7 +7153,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
|
||||
|
||||
if( nTries==1 ){
|
||||
conchModTime = buf.st_mtimespec;
|
||||
usleep(500000); /* wait 0.5 sec and try the lock again*/
|
||||
unixSleep(0,500000); /* wait 0.5 sec and try the lock again*/
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -7175,7 +7179,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
|
||||
/* don't break the lock on short read or a version mismatch */
|
||||
return SQLITE_BUSY;
|
||||
}
|
||||
usleep(10000000); /* wait 10 sec and try the lock again */
|
||||
unixSleep(0,10000000); /* wait 10 sec and try the lock again */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user