85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
** Disable the backoffice
*/
void backoffice_no_delay(void){
backofficeNoDelay = 1;
}
/*
** Parse a unsigned 64-bit integer from a string. Return a pointer
** to the character of z[] that occurs after the integer.
*/
static const char *backofficeParseInt(const char *z, sqlite3_uint64 *pVal){
*pVal = 0;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
** Disable the backoffice
*/
void backoffice_no_delay(void){
backofficeNoDelay = 1;
}
/*
** Sleeps for the specified number of milliseconds -OR- until interrupted
** by another thread (if supported by the underlying platform). Non-zero
** will be returned if the sleep was interrupted.
*/
static int backofficeSleep(int milliseconds){
#if defined(_WIN32)
assert( milliseconds>=0 );
if( SleepEx((DWORD)milliseconds, TRUE)==WAIT_IO_COMPLETION ){
return 1;
}
#else
sqlite3_sleep(milliseconds);
#endif
return 0;
}
/*
** Parse a unsigned 64-bit integer from a string. Return a pointer
** to the character of z[] that occurs after the integer.
*/
static const char *backofficeParseInt(const char *z, sqlite3_uint64 *pVal){
*pVal = 0;
|
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME;
backofficeWriteLease(&x);
db_end_transaction(0);
if( g.fAnyTrace ){
fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid());
}
if( x.tmCurrent >= tmNow ){
sqlite3_sleep(1000*(x.tmCurrent - tmNow + 1));
}else{
if( lastWarning+warningDelay < tmNow ){
fossil_warning(
"backoffice process %lld still running after %d seconds",
x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent));
lastWarning = tmNow;
warningDelay *= 2;
}
sqlite3_sleep(1000);
}
}
#if defined(_WIN32)
backofficeWin32ThreadCleanup();
#endif
return;
}
|
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME;
backofficeWriteLease(&x);
db_end_transaction(0);
if( g.fAnyTrace ){
fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid());
}
if( x.tmCurrent >= tmNow ){
if( backofficeSleep(1000*(x.tmCurrent - tmNow + 1)) ){
/* The sleep was interrupted by a signal from another thread. */
if( g.fAnyTrace ){
fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid());
}
db_end_transaction(0);
break;
}
}else{
if( lastWarning+warningDelay < tmNow ){
fossil_warning(
"backoffice process %lld still running after %d seconds",
x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent));
lastWarning = tmNow;
warningDelay *= 2;
}
if( backofficeSleep(1000) ){
/* The sleep was interrupted by a signal from another thread. */
if( g.fAnyTrace ){
fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid());
}
db_end_transaction(0);
break;
}
}
}
#if defined(_WIN32)
backofficeWin32ThreadCleanup();
#endif
return;
}
|