Fossil SCM
Change backoffice-nodelay to default off.
Commit
12c487c46f1f36bbbb52c2abd53724e9dc1d9699ad3faba3ab0c9dc61d21b8e8
Parent
3c0848797d1c7e1…
2 files changed
+9
-29
+1
-1
+9
-29
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -62,13 +62,10 @@ | ||
| 62 | 62 | #include <time.h> |
| 63 | 63 | #if defined(_WIN32) |
| 64 | 64 | # include <windows.h> |
| 65 | 65 | # include <stdio.h> |
| 66 | 66 | # include <process.h> |
| 67 | -# if defined(__MINGW32__) | |
| 68 | -# include <wchar.h> | |
| 69 | -# endif | |
| 70 | 67 | # define GETPID (int)GetCurrentProcessId |
| 71 | 68 | #else |
| 72 | 69 | # include <unistd.h> |
| 73 | 70 | # include <sys/types.h> |
| 74 | 71 | # include <signal.h> |
| @@ -283,38 +280,21 @@ | ||
| 283 | 280 | fossil_panic("backoffice timeout (%d seconds)", x); |
| 284 | 281 | } |
| 285 | 282 | #if defined(_WIN32) |
| 286 | 283 | static void *threadHandle = NULL; |
| 287 | 284 | static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */ |
| 288 | -static void backofficeWin32ThreadCleanup(int bStrict){ | |
| 285 | +static void backofficeWin32ThreadCleanup(){ | |
| 289 | 286 | if( threadHandle!=NULL ){ |
| 290 | 287 | /* Queue no-op asynchronous procedure call to the sleeping |
| 291 | 288 | * thread. This will cause it to wake up with a non-zero |
| 292 | 289 | * return value. */ |
| 293 | 290 | if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){ |
| 294 | 291 | /* Wait for the thread to wake up and then exit. */ |
| 295 | 292 | 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 | 293 | } |
| 310 | 294 | CloseHandle(threadHandle); |
| 311 | 295 | threadHandle = NULL; |
| 312 | - }else if(bStrict){ | |
| 313 | - fossil_panic( | |
| 314 | - "backofficeWin32ThreadCleanup: no timeout thread handle" | |
| 315 | - ); | |
| 316 | 296 | } |
| 317 | 297 | } |
| 318 | 298 | static unsigned __stdcall backofficeWin32SigalrmThreadProc( |
| 319 | 299 | void *pArg /* IN: Pointer to integer number of whole seconds. */ |
| 320 | 300 | ){ |
| @@ -326,11 +306,11 @@ | ||
| 326 | 306 | return 0; /* NOT REACHED */ |
| 327 | 307 | } |
| 328 | 308 | #endif |
| 329 | 309 | static void backofficeTimeout(int x){ |
| 330 | 310 | #if defined(_WIN32) |
| 331 | - backofficeWin32ThreadCleanup(0); | |
| 311 | + backofficeWin32ThreadCleanup(); | |
| 332 | 312 | threadHandle = (void*)_beginthreadex( |
| 333 | 313 | 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0 |
| 334 | 314 | ); |
| 335 | 315 | #else |
| 336 | 316 | signal(SIGALRM, backofficeSigalrmHandler); |
| @@ -453,11 +433,11 @@ | ||
| 453 | 433 | GETPID()); |
| 454 | 434 | } |
| 455 | 435 | backoffice_work(); |
| 456 | 436 | break; |
| 457 | 437 | } |
| 458 | - if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",1) ){ | |
| 438 | + if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){ | |
| 459 | 439 | /* If the no-delay flag is set, exit immediately rather than queuing |
| 460 | 440 | ** up. Assume that some future request will come along and handle any |
| 461 | 441 | ** necessary backoffice work. */ |
| 462 | 442 | db_end_transaction(0); |
| 463 | 443 | break; |
| @@ -497,11 +477,11 @@ | ||
| 497 | 477 | break; |
| 498 | 478 | } |
| 499 | 479 | } |
| 500 | 480 | } |
| 501 | 481 | #if defined(_WIN32) |
| 502 | - backofficeWin32ThreadCleanup(1); | |
| 482 | + backofficeWin32ThreadCleanup(); | |
| 503 | 483 | #endif |
| 504 | 484 | return; |
| 505 | 485 | } |
| 506 | 486 | |
| 507 | 487 | /* |
| @@ -515,11 +495,11 @@ | ||
| 515 | 495 | char *zLog = db_get("backoffice-logfile",0); |
| 516 | 496 | if( zLog && zLog[0] ){ |
| 517 | 497 | FILE *pLog = fossil_fopen(zLog, "a"); |
| 518 | 498 | if( pLog ){ |
| 519 | 499 | 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()); | |
| 521 | 501 | fclose(pLog); |
| 522 | 502 | } |
| 523 | 503 | } |
| 524 | 504 | |
| 525 | 505 | /* Here is where the actual work of the backoffice happens */ |
| @@ -561,16 +541,16 @@ | ||
| 561 | 541 | argv[1] = "backoffice"; |
| 562 | 542 | argv[2] = "-R"; |
| 563 | 543 | argv[3] = backofficeDb; |
| 564 | 544 | ax[4] = 0; |
| 565 | 545 | 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); | |
| 567 | 547 | for(i=0; i<=3; i++) fossil_unicode_free(ax[i]); |
| 568 | 548 | if( g.fAnyTrace ){ |
| 569 | 549 | fprintf(stderr, |
| 570 | 550 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 571 | - GETPID(), (int)x); | |
| 551 | + getpid(), (int)x); | |
| 572 | 552 | } |
| 573 | 553 | if( x>=0 ) return; |
| 574 | 554 | } |
| 575 | 555 | #else /* unix */ |
| 576 | 556 | { |
| @@ -578,11 +558,11 @@ | ||
| 578 | 558 | if( pid>0 ){ |
| 579 | 559 | /* This is the parent in a successful fork(). Return immediately. */ |
| 580 | 560 | if( g.fAnyTrace ){ |
| 581 | 561 | fprintf(stderr, |
| 582 | 562 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 583 | - GETPID(), (int)pid); | |
| 563 | + getpid(), (int)pid); | |
| 584 | 564 | } |
| 585 | 565 | return; |
| 586 | 566 | } |
| 587 | 567 | if( pid==0 ){ |
| 588 | 568 | /* This is the child of a successful fork(). Run backoffice. */ |
| @@ -590,11 +570,11 @@ | ||
| 590 | 570 | db_open_repository(backofficeDb); |
| 591 | 571 | backofficeDb = "x"; |
| 592 | 572 | backoffice_thread(); |
| 593 | 573 | db_close(1); |
| 594 | 574 | if( g.fAnyTrace ){ |
| 595 | - fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID()); | |
| 575 | + fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid()); | |
| 596 | 576 | } |
| 597 | 577 | exit(0); |
| 598 | 578 | } |
| 599 | 579 | } |
| 600 | 580 | #endif |
| 601 | 581 |
| --- 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 |
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3023,11 +3023,11 @@ | ||
| 3023 | 3023 | ** If autosync is enabled setting this to a value greater |
| 3024 | 3024 | ** than zero will cause autosync to try no more than this |
| 3025 | 3025 | ** number of attempts if there is a sync failure. |
| 3026 | 3026 | */ |
| 3027 | 3027 | /* |
| 3028 | -** SETTING: backoffice-nodelay boolean default=on | |
| 3028 | +** SETTING: backoffice-nodelay boolean default=off | |
| 3029 | 3029 | ** If backoffice-nodelay is true, then the backoffice processing |
| 3030 | 3030 | ** will never invoke sleep(). If it has nothing useful to do, |
| 3031 | 3031 | ** it simply exits. |
| 3032 | 3032 | */ |
| 3033 | 3033 | /* |
| 3034 | 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=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 |