Fossil SCM
Wrap use of getpid() in the trace statements.
Commit
842bf225d2b93e896d544d7f232ef0f9bd9bf585627bdd1eaf694cc804f6d999
Parent
9840313b1ce0b52…
1 file changed
+7
-9
+7
-9
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -42,14 +42,16 @@ | ||
| 42 | 42 | #include "backoffice.h" |
| 43 | 43 | #include <time.h> |
| 44 | 44 | #if defined(_WIN32) |
| 45 | 45 | # include <process.h> |
| 46 | 46 | # include <windows.h> |
| 47 | +# define GETPID (int)GetCurrentProcessId | |
| 47 | 48 | #else |
| 48 | 49 | # include <unistd.h> |
| 49 | 50 | # include <sys/types.h> |
| 50 | 51 | # include <signal.h> |
| 52 | +# define GETPID getpid | |
| 51 | 53 | #endif |
| 52 | 54 | |
| 53 | 55 | /* |
| 54 | 56 | ** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice |
| 55 | 57 | ** processing run is valid. Each backoffice run monopolizes the lease for |
| @@ -195,15 +197,11 @@ | ||
| 195 | 197 | |
| 196 | 198 | /* |
| 197 | 199 | ** Return a process id number for the current process |
| 198 | 200 | */ |
| 199 | 201 | static sqlite3_uint64 backofficeProcessId(void){ |
| 200 | -#if defined(_WIN32) | |
| 201 | - return (sqlite3_uint64)GetCurrentProcessId(); | |
| 202 | -#else | |
| 203 | - return (sqlite3_uint64)getpid(); | |
| 204 | -#endif | |
| 202 | + return (sqlite3_uint64)GETPID(); | |
| 205 | 203 | } |
| 206 | 204 | |
| 207 | 205 | /* |
| 208 | 206 | ** Set an alarm to cause the process to exit after "x" seconds. This |
| 209 | 207 | ** prevents any kind of bug from keeping a backoffice process running |
| @@ -325,11 +323,11 @@ | ||
| 325 | 323 | x.tmNext = 0; |
| 326 | 324 | backofficeWriteLease(&x); |
| 327 | 325 | db_end_transaction(0); |
| 328 | 326 | if( g.fAnyTrace ){ |
| 329 | 327 | fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n", |
| 330 | - getpid()); | |
| 328 | + GETPID()); | |
| 331 | 329 | } |
| 332 | 330 | backoffice_work(); |
| 333 | 331 | break; |
| 334 | 332 | } |
| 335 | 333 | if( backofficeNoDelay ){ |
| @@ -344,17 +342,17 @@ | ||
| 344 | 342 | x.idNext = idSelf; |
| 345 | 343 | x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME; |
| 346 | 344 | backofficeWriteLease(&x); |
| 347 | 345 | db_end_transaction(0); |
| 348 | 346 | if( g.fAnyTrace ){ |
| 349 | - fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid()); | |
| 347 | + fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", GETPID()); | |
| 350 | 348 | } |
| 351 | 349 | if( x.tmCurrent >= tmNow ){ |
| 352 | 350 | if( backofficeSleep(1000*(x.tmCurrent - tmNow + 1)) ){ |
| 353 | 351 | /* The sleep was interrupted by a signal from another thread. */ |
| 354 | 352 | if( g.fAnyTrace ){ |
| 355 | - fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid()); | |
| 353 | + fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID()); | |
| 356 | 354 | } |
| 357 | 355 | db_end_transaction(0); |
| 358 | 356 | break; |
| 359 | 357 | } |
| 360 | 358 | }else{ |
| @@ -366,11 +364,11 @@ | ||
| 366 | 364 | warningDelay *= 2; |
| 367 | 365 | } |
| 368 | 366 | if( backofficeSleep(1000) ){ |
| 369 | 367 | /* The sleep was interrupted by a signal from another thread. */ |
| 370 | 368 | if( g.fAnyTrace ){ |
| 371 | - fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid()); | |
| 369 | + fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID()); | |
| 372 | 370 | } |
| 373 | 371 | db_end_transaction(0); |
| 374 | 372 | break; |
| 375 | 373 | } |
| 376 | 374 | } |
| 377 | 375 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -42,14 +42,16 @@ | |
| 42 | #include "backoffice.h" |
| 43 | #include <time.h> |
| 44 | #if defined(_WIN32) |
| 45 | # include <process.h> |
| 46 | # include <windows.h> |
| 47 | #else |
| 48 | # include <unistd.h> |
| 49 | # include <sys/types.h> |
| 50 | # include <signal.h> |
| 51 | #endif |
| 52 | |
| 53 | /* |
| 54 | ** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice |
| 55 | ** processing run is valid. Each backoffice run monopolizes the lease for |
| @@ -195,15 +197,11 @@ | |
| 195 | |
| 196 | /* |
| 197 | ** Return a process id number for the current process |
| 198 | */ |
| 199 | static sqlite3_uint64 backofficeProcessId(void){ |
| 200 | #if defined(_WIN32) |
| 201 | return (sqlite3_uint64)GetCurrentProcessId(); |
| 202 | #else |
| 203 | return (sqlite3_uint64)getpid(); |
| 204 | #endif |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | ** Set an alarm to cause the process to exit after "x" seconds. This |
| 209 | ** prevents any kind of bug from keeping a backoffice process running |
| @@ -325,11 +323,11 @@ | |
| 325 | x.tmNext = 0; |
| 326 | backofficeWriteLease(&x); |
| 327 | db_end_transaction(0); |
| 328 | if( g.fAnyTrace ){ |
| 329 | fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n", |
| 330 | getpid()); |
| 331 | } |
| 332 | backoffice_work(); |
| 333 | break; |
| 334 | } |
| 335 | if( backofficeNoDelay ){ |
| @@ -344,17 +342,17 @@ | |
| 344 | x.idNext = idSelf; |
| 345 | x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME; |
| 346 | backofficeWriteLease(&x); |
| 347 | db_end_transaction(0); |
| 348 | if( g.fAnyTrace ){ |
| 349 | fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid()); |
| 350 | } |
| 351 | if( x.tmCurrent >= tmNow ){ |
| 352 | if( backofficeSleep(1000*(x.tmCurrent - tmNow + 1)) ){ |
| 353 | /* The sleep was interrupted by a signal from another thread. */ |
| 354 | if( g.fAnyTrace ){ |
| 355 | fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid()); |
| 356 | } |
| 357 | db_end_transaction(0); |
| 358 | break; |
| 359 | } |
| 360 | }else{ |
| @@ -366,11 +364,11 @@ | |
| 366 | warningDelay *= 2; |
| 367 | } |
| 368 | if( backofficeSleep(1000) ){ |
| 369 | /* The sleep was interrupted by a signal from another thread. */ |
| 370 | if( g.fAnyTrace ){ |
| 371 | fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid()); |
| 372 | } |
| 373 | db_end_transaction(0); |
| 374 | break; |
| 375 | } |
| 376 | } |
| 377 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -42,14 +42,16 @@ | |
| 42 | #include "backoffice.h" |
| 43 | #include <time.h> |
| 44 | #if defined(_WIN32) |
| 45 | # include <process.h> |
| 46 | # include <windows.h> |
| 47 | # define GETPID (int)GetCurrentProcessId |
| 48 | #else |
| 49 | # include <unistd.h> |
| 50 | # include <sys/types.h> |
| 51 | # include <signal.h> |
| 52 | # define GETPID getpid |
| 53 | #endif |
| 54 | |
| 55 | /* |
| 56 | ** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice |
| 57 | ** processing run is valid. Each backoffice run monopolizes the lease for |
| @@ -195,15 +197,11 @@ | |
| 197 | |
| 198 | /* |
| 199 | ** Return a process id number for the current process |
| 200 | */ |
| 201 | static sqlite3_uint64 backofficeProcessId(void){ |
| 202 | return (sqlite3_uint64)GETPID(); |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | ** Set an alarm to cause the process to exit after "x" seconds. This |
| 207 | ** prevents any kind of bug from keeping a backoffice process running |
| @@ -325,11 +323,11 @@ | |
| 323 | x.tmNext = 0; |
| 324 | backofficeWriteLease(&x); |
| 325 | db_end_transaction(0); |
| 326 | if( g.fAnyTrace ){ |
| 327 | fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n", |
| 328 | GETPID()); |
| 329 | } |
| 330 | backoffice_work(); |
| 331 | break; |
| 332 | } |
| 333 | if( backofficeNoDelay ){ |
| @@ -344,17 +342,17 @@ | |
| 342 | x.idNext = idSelf; |
| 343 | x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME; |
| 344 | backofficeWriteLease(&x); |
| 345 | db_end_transaction(0); |
| 346 | if( g.fAnyTrace ){ |
| 347 | fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", GETPID()); |
| 348 | } |
| 349 | if( x.tmCurrent >= tmNow ){ |
| 350 | if( backofficeSleep(1000*(x.tmCurrent - tmNow + 1)) ){ |
| 351 | /* The sleep was interrupted by a signal from another thread. */ |
| 352 | if( g.fAnyTrace ){ |
| 353 | fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID()); |
| 354 | } |
| 355 | db_end_transaction(0); |
| 356 | break; |
| 357 | } |
| 358 | }else{ |
| @@ -366,11 +364,11 @@ | |
| 364 | warningDelay *= 2; |
| 365 | } |
| 366 | if( backofficeSleep(1000) ){ |
| 367 | /* The sleep was interrupted by a signal from another thread. */ |
| 368 | if( g.fAnyTrace ){ |
| 369 | fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID()); |
| 370 | } |
| 371 | db_end_transaction(0); |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 |