Fossil

Check-in [9840313b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When sleeping inside the backoffice work loop, permit the sleep to be interrupted on Win32, which stops processing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | win32Proc
Files: files | file ages | folders
SHA3-256:9840313b1ce0b528bbedbfcd0cea921c2058a2b822bdef452e44acd4dee2151e
User & Date: mistachkin 2018-08-02 02:27:51
Context
2018-08-02
03:03
Wrap use of getpid() in the trace statements. check-in: 842bf225 user: mistachkin tags: win32Proc
02:27
When sleeping inside the backoffice work loop, permit the sleep to be interrupted on Win32, which stops processing. check-in: 9840313b user: mistachkin tags: win32Proc
01:53
More Win32 support for the backoffice processing. check-in: f13ae35f user: mistachkin tags: win32Proc
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/backoffice.c.

85
86
87
88
89
90
91

















92
93
94
95
96
97
98
...
328
329
330
331
332
333
334
335







336
337
338
339
340
341
342
343
344







345
346
347
348
349
350
351
/*
** 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;
................................................................................
    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;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
>
>
>
>
>
>








|
>
>
>
>
>
>
>







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
...
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
/*
** 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;
................................................................................
    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;
}