Fossil SCM

Go ahead and permanently remove the backoffice timeout mechanism, as it seems clear we will not have a use for it moving forward.

drh 2018-08-08 23:59 trunk
Commit 4db384875273f5375b62758f8d5e0bcf8fef15b81208450504044f10304388da
1 file changed -69
--- src/backoffice.c
+++ src/backoffice.c
@@ -305,78 +305,10 @@
305305
*/
306306
static sqlite3_uint64 backofficeProcessId(void){
307307
return (sqlite3_uint64)GETPID();
308308
}
309309
310
-#if 0 /* Disable the backoffice timeout for now */
311
-/*
312
-** Set an alarm to cause the process to exit after "x" seconds. This
313
-** prevents any kind of bug from keeping a backoffice process running
314
-** indefinitely.
315
-*/
316
-static void backofficeSigalrmHandler(int x){
317
- fossil_panic("backoffice timeout (%d seconds)", x);
318
-}
319
-#if defined(_WIN32)
320
-static void *threadHandle = NULL;
321
-static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */
322
-static void backofficeWin32ThreadCleanup(int bStrict){
323
- if( threadHandle!=NULL ){
324
- /* Queue no-op asynchronous procedure call to the sleeping
325
- * thread. This will cause it to wake up with a non-zero
326
- * return value. */
327
- if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){
328
- /* Wait for the thread to wake up and then exit. */
329
- WaitForSingleObject(threadHandle, INFINITE);
330
- }else if(bStrict){
331
- DWORD dwLastError = GetLastError();
332
- fossil_errorlog(
333
- "backofficeWin32ThreadCleanup: QueueUserAPC failed, code %lu",
334
- dwLastError
335
- );
336
- if( !TerminateThread(threadHandle, dwLastError) ){
337
- dwLastError = GetLastError();
338
- fossil_panic(
339
- "backofficeWin32ThreadCleanup: TerminateThread failed, code %lu",
340
- dwLastError
341
- );
342
- }
343
- }
344
- CloseHandle(threadHandle);
345
- threadHandle = NULL;
346
- }else if(bStrict){
347
- fossil_panic(
348
- "backofficeWin32ThreadCleanup: no timeout thread handle"
349
- );
350
- }
351
-}
352
-static unsigned __stdcall backofficeWin32SigalrmThreadProc(
353
- void *pArg /* IN: Pointer to integer number of whole seconds. */
354
-){
355
- int seconds = FOSSIL_PTR_TO_INT(pArg);
356
- if( SleepEx((DWORD)seconds * 1000, TRUE)==0 ){
357
- backofficeSigalrmHandler(seconds);
358
- }
359
- _endthreadex(0);
360
- return 0; /* NOT REACHED */
361
-}
362
-#endif
363
-static void backofficeTimeout(int x){
364
-#if defined(_WIN32)
365
- backofficeWin32ThreadCleanup(0);
366
- threadHandle = (void*)_beginthreadex(
367
- 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0
368
- );
369
-#else
370
- signal(SIGALRM, backofficeSigalrmHandler);
371
- alarm(x);
372
-#endif
373
-}
374
-#else /* Real timeout (above) is disabled. In its place is the following */
375
- /* stub routine */
376
-static void backofficeTimeout(int x){ /* no-op */ }
377
-#endif
378310
379311
/*
380312
** COMMAND: test-process-id
381313
**
382314
** Usage: %fossil [--sleep N] PROCESS-ID ...
@@ -499,11 +431,10 @@
499431
int lastWarning = 0;
500432
int warningDelay = 30;
501433
static int once = 0;
502434
503435
backoffice_error_check_one(&once);
504
- backofficeTimeout(BKOFCE_LEASE_TIME*2);
505436
idSelf = backofficeProcessId();
506437
while(1){
507438
tmNow = time(0);
508439
db_begin_write();
509440
backofficeReadLease(&x);
510441
--- src/backoffice.c
+++ src/backoffice.c
@@ -305,78 +305,10 @@
305 */
306 static sqlite3_uint64 backofficeProcessId(void){
307 return (sqlite3_uint64)GETPID();
308 }
309
310 #if 0 /* Disable the backoffice timeout for now */
311 /*
312 ** Set an alarm to cause the process to exit after "x" seconds. This
313 ** prevents any kind of bug from keeping a backoffice process running
314 ** indefinitely.
315 */
316 static void backofficeSigalrmHandler(int x){
317 fossil_panic("backoffice timeout (%d seconds)", x);
318 }
319 #if defined(_WIN32)
320 static void *threadHandle = NULL;
321 static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */
322 static void backofficeWin32ThreadCleanup(int bStrict){
323 if( threadHandle!=NULL ){
324 /* Queue no-op asynchronous procedure call to the sleeping
325 * thread. This will cause it to wake up with a non-zero
326 * return value. */
327 if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){
328 /* Wait for the thread to wake up and then exit. */
329 WaitForSingleObject(threadHandle, INFINITE);
330 }else if(bStrict){
331 DWORD dwLastError = GetLastError();
332 fossil_errorlog(
333 "backofficeWin32ThreadCleanup: QueueUserAPC failed, code %lu",
334 dwLastError
335 );
336 if( !TerminateThread(threadHandle, dwLastError) ){
337 dwLastError = GetLastError();
338 fossil_panic(
339 "backofficeWin32ThreadCleanup: TerminateThread failed, code %lu",
340 dwLastError
341 );
342 }
343 }
344 CloseHandle(threadHandle);
345 threadHandle = NULL;
346 }else if(bStrict){
347 fossil_panic(
348 "backofficeWin32ThreadCleanup: no timeout thread handle"
349 );
350 }
351 }
352 static unsigned __stdcall backofficeWin32SigalrmThreadProc(
353 void *pArg /* IN: Pointer to integer number of whole seconds. */
354 ){
355 int seconds = FOSSIL_PTR_TO_INT(pArg);
356 if( SleepEx((DWORD)seconds * 1000, TRUE)==0 ){
357 backofficeSigalrmHandler(seconds);
358 }
359 _endthreadex(0);
360 return 0; /* NOT REACHED */
361 }
362 #endif
363 static void backofficeTimeout(int x){
364 #if defined(_WIN32)
365 backofficeWin32ThreadCleanup(0);
366 threadHandle = (void*)_beginthreadex(
367 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0
368 );
369 #else
370 signal(SIGALRM, backofficeSigalrmHandler);
371 alarm(x);
372 #endif
373 }
374 #else /* Real timeout (above) is disabled. In its place is the following */
375 /* stub routine */
376 static void backofficeTimeout(int x){ /* no-op */ }
377 #endif
378
379 /*
380 ** COMMAND: test-process-id
381 **
382 ** Usage: %fossil [--sleep N] PROCESS-ID ...
@@ -499,11 +431,10 @@
499 int lastWarning = 0;
500 int warningDelay = 30;
501 static int once = 0;
502
503 backoffice_error_check_one(&once);
504 backofficeTimeout(BKOFCE_LEASE_TIME*2);
505 idSelf = backofficeProcessId();
506 while(1){
507 tmNow = time(0);
508 db_begin_write();
509 backofficeReadLease(&x);
510
--- src/backoffice.c
+++ src/backoffice.c
@@ -305,78 +305,10 @@
305 */
306 static sqlite3_uint64 backofficeProcessId(void){
307 return (sqlite3_uint64)GETPID();
308 }
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
311 /*
312 ** COMMAND: test-process-id
313 **
314 ** Usage: %fossil [--sleep N] PROCESS-ID ...
@@ -499,11 +431,10 @@
431 int lastWarning = 0;
432 int warningDelay = 30;
433 static int once = 0;
434
435 backoffice_error_check_one(&once);
 
436 idSelf = backofficeProcessId();
437 while(1){
438 tmNow = time(0);
439 db_begin_write();
440 backofficeReadLease(&x);
441

Keyboard Shortcuts

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