1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix the threadtest3 test program so that it works with VFSes that omit the

xCurrentTime() method and supply only xCurrentTimeInt64().

FossilOrigin-Name: 3b155855f3d5918f1df7dbd19783215b3da0ca3e
This commit is contained in:
drh
2015-11-30 19:15:25 +00:00
parent d6b459c996
commit f8b0be48d1
3 changed files with 26 additions and 26 deletions

View File

@ -868,22 +868,28 @@ static void filecopy_x(
** Used by setstoptime() and timetostop().
*/
static double timelimit = 0.0;
static sqlite3_vfs *pTimelimitVfs = 0;
static double currentTime(void){
double t;
static sqlite3_vfs *pTimelimitVfs = 0;
if( pTimelimitVfs==0 ) pTimelimitVfs = sqlite3_vfs_find(0);
if( pTimelimitVfs->iVersion>=1 && pTimelimitVfs->xCurrentTimeInt64!=0 ){
sqlite3_int64 tm;
pTimelimitVfs->xCurrentTimeInt64(pTimelimitVfs, &tm);
t = tm/86400000.0;
}else{
pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
}
return t;
}
static void setstoptime_x(
Error *pErr, /* IN/OUT: Error code */
int nMs /* Milliseconds until "stop time" */
){
if( pErr->rc==SQLITE_OK ){
double t;
int rc;
pTimelimitVfs = sqlite3_vfs_find(0);
rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
if( rc!=SQLITE_OK ){
pErr->rc = rc;
}else{
timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0);
}
double t = currentTime();
timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0);
}
}
@ -892,14 +898,8 @@ static int timetostop_x(
){
int ret = 1;
if( pErr->rc==SQLITE_OK ){
double t;
int rc;
rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
if( rc!=SQLITE_OK ){
pErr->rc = rc;
}else{
ret = (t >= timelimit);
}
double t = currentTime();
ret = (t >= timelimit);
}
return ret;
}