Fossil SCM

Change backoffice-nodelay to default off.

drh 2018-08-07 23:16 trunk
Commit 12c487c46f1f36bbbb52c2abd53724e9dc1d9699ad3faba3ab0c9dc61d21b8e8
2 files changed +9 -29 +1 -1
+9 -29
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,13 +62,10 @@
6262
#include <time.h>
6363
#if defined(_WIN32)
6464
# include <windows.h>
6565
# include <stdio.h>
6666
# include <process.h>
67
-# if defined(__MINGW32__)
68
-# include <wchar.h>
69
-# endif
7067
# define GETPID (int)GetCurrentProcessId
7168
#else
7269
# include <unistd.h>
7370
# include <sys/types.h>
7471
# include <signal.h>
@@ -283,38 +280,21 @@
283280
fossil_panic("backoffice timeout (%d seconds)", x);
284281
}
285282
#if defined(_WIN32)
286283
static void *threadHandle = NULL;
287284
static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */
288
-static void backofficeWin32ThreadCleanup(int bStrict){
285
+static void backofficeWin32ThreadCleanup(){
289286
if( threadHandle!=NULL ){
290287
/* Queue no-op asynchronous procedure call to the sleeping
291288
* thread. This will cause it to wake up with a non-zero
292289
* return value. */
293290
if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){
294291
/* Wait for the thread to wake up and then exit. */
295292
WaitForSingleObject(threadHandle, INFINITE);
296
- }else if(bStrict){
297
- DWORD dwLastError = GetLastError();
298
- fossil_errorlog(
299
- "backofficeWin32ThreadCleanup: QueueUserAPC failed, code %lu",
300
- dwLastError
301
- );
302
- if( !TerminateThread(threadHandle, dwLastError) ){
303
- dwLastError = GetLastError();
304
- fossil_panic(
305
- "backofficeWin32ThreadCleanup: TerminateThread failed, code %lu",
306
- dwLastError
307
- );
308
- }
309293
}
310294
CloseHandle(threadHandle);
311295
threadHandle = NULL;
312
- }else if(bStrict){
313
- fossil_panic(
314
- "backofficeWin32ThreadCleanup: no timeout thread handle"
315
- );
316296
}
317297
}
318298
static unsigned __stdcall backofficeWin32SigalrmThreadProc(
319299
void *pArg /* IN: Pointer to integer number of whole seconds. */
320300
){
@@ -326,11 +306,11 @@
326306
return 0; /* NOT REACHED */
327307
}
328308
#endif
329309
static void backofficeTimeout(int x){
330310
#if defined(_WIN32)
331
- backofficeWin32ThreadCleanup(0);
311
+ backofficeWin32ThreadCleanup();
332312
threadHandle = (void*)_beginthreadex(
333313
0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0
334314
);
335315
#else
336316
signal(SIGALRM, backofficeSigalrmHandler);
@@ -453,11 +433,11 @@
453433
GETPID());
454434
}
455435
backoffice_work();
456436
break;
457437
}
458
- if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",1) ){
438
+ if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
459439
/* If the no-delay flag is set, exit immediately rather than queuing
460440
** up. Assume that some future request will come along and handle any
461441
** necessary backoffice work. */
462442
db_end_transaction(0);
463443
break;
@@ -497,11 +477,11 @@
497477
break;
498478
}
499479
}
500480
}
501481
#if defined(_WIN32)
502
- backofficeWin32ThreadCleanup(1);
482
+ backofficeWin32ThreadCleanup();
503483
#endif
504484
return;
505485
}
506486
507487
/*
@@ -515,11 +495,11 @@
515495
char *zLog = db_get("backoffice-logfile",0);
516496
if( zLog && zLog[0] ){
517497
FILE *pLog = fossil_fopen(zLog, "a");
518498
if( pLog ){
519499
char *zDate = db_text(0, "SELECT datetime('now');");
520
- fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
500
+ fprintf(pLog, "%s (%d) backoffice running\n", zDate, getpid());
521501
fclose(pLog);
522502
}
523503
}
524504
525505
/* Here is where the actual work of the backoffice happens */
@@ -561,16 +541,16 @@
561541
argv[1] = "backoffice";
562542
argv[2] = "-R";
563543
argv[3] = backofficeDb;
564544
ax[4] = 0;
565545
for(i=0; i<=3; i++) ax[i] = fossil_utf8_to_unicode(argv[i]);
566
- x = _wspawnv(_P_NOWAIT, ax[0], (const wchar_t * const *)ax);
546
+ x = _wspawnv(_P_NOWAIT, ax[0], ax);
567547
for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);
568548
if( g.fAnyTrace ){
569549
fprintf(stderr,
570550
"/***** Subprocess %d creates backoffice child %d *****/\n",
571
- GETPID(), (int)x);
551
+ getpid(), (int)x);
572552
}
573553
if( x>=0 ) return;
574554
}
575555
#else /* unix */
576556
{
@@ -578,11 +558,11 @@
578558
if( pid>0 ){
579559
/* This is the parent in a successful fork(). Return immediately. */
580560
if( g.fAnyTrace ){
581561
fprintf(stderr,
582562
"/***** Subprocess %d creates backoffice child %d *****/\n",
583
- GETPID(), (int)pid);
563
+ getpid(), (int)pid);
584564
}
585565
return;
586566
}
587567
if( pid==0 ){
588568
/* This is the child of a successful fork(). Run backoffice. */
@@ -590,11 +570,11 @@
590570
db_open_repository(backofficeDb);
591571
backofficeDb = "x";
592572
backoffice_thread();
593573
db_close(1);
594574
if( g.fAnyTrace ){
595
- fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID());
575
+ fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid());
596576
}
597577
exit(0);
598578
}
599579
}
600580
#endif
601581
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,13 +62,10 @@
62 #include <time.h>
63 #if defined(_WIN32)
64 # include <windows.h>
65 # include <stdio.h>
66 # include <process.h>
67 # if defined(__MINGW32__)
68 # include <wchar.h>
69 # endif
70 # define GETPID (int)GetCurrentProcessId
71 #else
72 # include <unistd.h>
73 # include <sys/types.h>
74 # include <signal.h>
@@ -283,38 +280,21 @@
283 fossil_panic("backoffice timeout (%d seconds)", x);
284 }
285 #if defined(_WIN32)
286 static void *threadHandle = NULL;
287 static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */
288 static void backofficeWin32ThreadCleanup(int bStrict){
289 if( threadHandle!=NULL ){
290 /* Queue no-op asynchronous procedure call to the sleeping
291 * thread. This will cause it to wake up with a non-zero
292 * return value. */
293 if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){
294 /* Wait for the thread to wake up and then exit. */
295 WaitForSingleObject(threadHandle, INFINITE);
296 }else if(bStrict){
297 DWORD dwLastError = GetLastError();
298 fossil_errorlog(
299 "backofficeWin32ThreadCleanup: QueueUserAPC failed, code %lu",
300 dwLastError
301 );
302 if( !TerminateThread(threadHandle, dwLastError) ){
303 dwLastError = GetLastError();
304 fossil_panic(
305 "backofficeWin32ThreadCleanup: TerminateThread failed, code %lu",
306 dwLastError
307 );
308 }
309 }
310 CloseHandle(threadHandle);
311 threadHandle = NULL;
312 }else if(bStrict){
313 fossil_panic(
314 "backofficeWin32ThreadCleanup: no timeout thread handle"
315 );
316 }
317 }
318 static unsigned __stdcall backofficeWin32SigalrmThreadProc(
319 void *pArg /* IN: Pointer to integer number of whole seconds. */
320 ){
@@ -326,11 +306,11 @@
326 return 0; /* NOT REACHED */
327 }
328 #endif
329 static void backofficeTimeout(int x){
330 #if defined(_WIN32)
331 backofficeWin32ThreadCleanup(0);
332 threadHandle = (void*)_beginthreadex(
333 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0
334 );
335 #else
336 signal(SIGALRM, backofficeSigalrmHandler);
@@ -453,11 +433,11 @@
453 GETPID());
454 }
455 backoffice_work();
456 break;
457 }
458 if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",1) ){
459 /* If the no-delay flag is set, exit immediately rather than queuing
460 ** up. Assume that some future request will come along and handle any
461 ** necessary backoffice work. */
462 db_end_transaction(0);
463 break;
@@ -497,11 +477,11 @@
497 break;
498 }
499 }
500 }
501 #if defined(_WIN32)
502 backofficeWin32ThreadCleanup(1);
503 #endif
504 return;
505 }
506
507 /*
@@ -515,11 +495,11 @@
515 char *zLog = db_get("backoffice-logfile",0);
516 if( zLog && zLog[0] ){
517 FILE *pLog = fossil_fopen(zLog, "a");
518 if( pLog ){
519 char *zDate = db_text(0, "SELECT datetime('now');");
520 fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
521 fclose(pLog);
522 }
523 }
524
525 /* Here is where the actual work of the backoffice happens */
@@ -561,16 +541,16 @@
561 argv[1] = "backoffice";
562 argv[2] = "-R";
563 argv[3] = backofficeDb;
564 ax[4] = 0;
565 for(i=0; i<=3; i++) ax[i] = fossil_utf8_to_unicode(argv[i]);
566 x = _wspawnv(_P_NOWAIT, ax[0], (const wchar_t * const *)ax);
567 for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);
568 if( g.fAnyTrace ){
569 fprintf(stderr,
570 "/***** Subprocess %d creates backoffice child %d *****/\n",
571 GETPID(), (int)x);
572 }
573 if( x>=0 ) return;
574 }
575 #else /* unix */
576 {
@@ -578,11 +558,11 @@
578 if( pid>0 ){
579 /* This is the parent in a successful fork(). Return immediately. */
580 if( g.fAnyTrace ){
581 fprintf(stderr,
582 "/***** Subprocess %d creates backoffice child %d *****/\n",
583 GETPID(), (int)pid);
584 }
585 return;
586 }
587 if( pid==0 ){
588 /* This is the child of a successful fork(). Run backoffice. */
@@ -590,11 +570,11 @@
590 db_open_repository(backofficeDb);
591 backofficeDb = "x";
592 backoffice_thread();
593 db_close(1);
594 if( g.fAnyTrace ){
595 fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID());
596 }
597 exit(0);
598 }
599 }
600 #endif
601
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,13 +62,10 @@
62 #include <time.h>
63 #if defined(_WIN32)
64 # include <windows.h>
65 # include <stdio.h>
66 # include <process.h>
 
 
 
67 # define GETPID (int)GetCurrentProcessId
68 #else
69 # include <unistd.h>
70 # include <sys/types.h>
71 # include <signal.h>
@@ -283,38 +280,21 @@
280 fossil_panic("backoffice timeout (%d seconds)", x);
281 }
282 #if defined(_WIN32)
283 static void *threadHandle = NULL;
284 static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */
285 static void backofficeWin32ThreadCleanup(){
286 if( threadHandle!=NULL ){
287 /* Queue no-op asynchronous procedure call to the sleeping
288 * thread. This will cause it to wake up with a non-zero
289 * return value. */
290 if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){
291 /* Wait for the thread to wake up and then exit. */
292 WaitForSingleObject(threadHandle, INFINITE);
 
 
 
 
 
 
 
 
 
 
 
 
 
293 }
294 CloseHandle(threadHandle);
295 threadHandle = NULL;
 
 
 
 
296 }
297 }
298 static unsigned __stdcall backofficeWin32SigalrmThreadProc(
299 void *pArg /* IN: Pointer to integer number of whole seconds. */
300 ){
@@ -326,11 +306,11 @@
306 return 0; /* NOT REACHED */
307 }
308 #endif
309 static void backofficeTimeout(int x){
310 #if defined(_WIN32)
311 backofficeWin32ThreadCleanup();
312 threadHandle = (void*)_beginthreadex(
313 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0
314 );
315 #else
316 signal(SIGALRM, backofficeSigalrmHandler);
@@ -453,11 +433,11 @@
433 GETPID());
434 }
435 backoffice_work();
436 break;
437 }
438 if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
439 /* If the no-delay flag is set, exit immediately rather than queuing
440 ** up. Assume that some future request will come along and handle any
441 ** necessary backoffice work. */
442 db_end_transaction(0);
443 break;
@@ -497,11 +477,11 @@
477 break;
478 }
479 }
480 }
481 #if defined(_WIN32)
482 backofficeWin32ThreadCleanup();
483 #endif
484 return;
485 }
486
487 /*
@@ -515,11 +495,11 @@
495 char *zLog = db_get("backoffice-logfile",0);
496 if( zLog && zLog[0] ){
497 FILE *pLog = fossil_fopen(zLog, "a");
498 if( pLog ){
499 char *zDate = db_text(0, "SELECT datetime('now');");
500 fprintf(pLog, "%s (%d) backoffice running\n", zDate, getpid());
501 fclose(pLog);
502 }
503 }
504
505 /* Here is where the actual work of the backoffice happens */
@@ -561,16 +541,16 @@
541 argv[1] = "backoffice";
542 argv[2] = "-R";
543 argv[3] = backofficeDb;
544 ax[4] = 0;
545 for(i=0; i<=3; i++) ax[i] = fossil_utf8_to_unicode(argv[i]);
546 x = _wspawnv(_P_NOWAIT, ax[0], ax);
547 for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);
548 if( g.fAnyTrace ){
549 fprintf(stderr,
550 "/***** Subprocess %d creates backoffice child %d *****/\n",
551 getpid(), (int)x);
552 }
553 if( x>=0 ) return;
554 }
555 #else /* unix */
556 {
@@ -578,11 +558,11 @@
558 if( pid>0 ){
559 /* This is the parent in a successful fork(). Return immediately. */
560 if( g.fAnyTrace ){
561 fprintf(stderr,
562 "/***** Subprocess %d creates backoffice child %d *****/\n",
563 getpid(), (int)pid);
564 }
565 return;
566 }
567 if( pid==0 ){
568 /* This is the child of a successful fork(). Run backoffice. */
@@ -590,11 +570,11 @@
570 db_open_repository(backofficeDb);
571 backofficeDb = "x";
572 backoffice_thread();
573 db_close(1);
574 if( g.fAnyTrace ){
575 fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid());
576 }
577 exit(0);
578 }
579 }
580 #endif
581
+1 -1
--- src/db.c
+++ src/db.c
@@ -3023,11 +3023,11 @@
30233023
** If autosync is enabled setting this to a value greater
30243024
** than zero will cause autosync to try no more than this
30253025
** number of attempts if there is a sync failure.
30263026
*/
30273027
/*
3028
-** SETTING: backoffice-nodelay boolean default=on
3028
+** SETTING: backoffice-nodelay boolean default=off
30293029
** If backoffice-nodelay is true, then the backoffice processing
30303030
** will never invoke sleep(). If it has nothing useful to do,
30313031
** it simply exits.
30323032
*/
30333033
/*
30343034
--- src/db.c
+++ src/db.c
@@ -3023,11 +3023,11 @@
3023 ** If autosync is enabled setting this to a value greater
3024 ** than zero will cause autosync to try no more than this
3025 ** number of attempts if there is a sync failure.
3026 */
3027 /*
3028 ** SETTING: backoffice-nodelay boolean default=on
3029 ** If backoffice-nodelay is true, then the backoffice processing
3030 ** will never invoke sleep(). If it has nothing useful to do,
3031 ** it simply exits.
3032 */
3033 /*
3034
--- src/db.c
+++ src/db.c
@@ -3023,11 +3023,11 @@
3023 ** If autosync is enabled setting this to a value greater
3024 ** than zero will cause autosync to try no more than this
3025 ** number of attempts if there is a sync failure.
3026 */
3027 /*
3028 ** SETTING: backoffice-nodelay boolean default=off
3029 ** If backoffice-nodelay is true, then the backoffice processing
3030 ** will never invoke sleep(). If it has nothing useful to do,
3031 ** it simply exits.
3032 */
3033 /*
3034

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button