Fossil SCM

Wrap use of getpid() in the trace statements.

mistachkin 2018-08-02 03:03 win32Proc
Commit 842bf225d2b93e896d544d7f232ef0f9bd9bf585627bdd1eaf694cc804f6d999
1 file changed +7 -9
--- src/backoffice.c
+++ src/backoffice.c
@@ -42,14 +42,16 @@
4242
#include "backoffice.h"
4343
#include <time.h>
4444
#if defined(_WIN32)
4545
# include <process.h>
4646
# include <windows.h>
47
+# define GETPID (int)GetCurrentProcessId
4748
#else
4849
# include <unistd.h>
4950
# include <sys/types.h>
5051
# include <signal.h>
52
+# define GETPID getpid
5153
#endif
5254
5355
/*
5456
** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice
5557
** processing run is valid. Each backoffice run monopolizes the lease for
@@ -195,15 +197,11 @@
195197
196198
/*
197199
** Return a process id number for the current process
198200
*/
199201
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();
205203
}
206204
207205
/*
208206
** Set an alarm to cause the process to exit after "x" seconds. This
209207
** prevents any kind of bug from keeping a backoffice process running
@@ -325,11 +323,11 @@
325323
x.tmNext = 0;
326324
backofficeWriteLease(&x);
327325
db_end_transaction(0);
328326
if( g.fAnyTrace ){
329327
fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n",
330
- getpid());
328
+ GETPID());
331329
}
332330
backoffice_work();
333331
break;
334332
}
335333
if( backofficeNoDelay ){
@@ -344,17 +342,17 @@
344342
x.idNext = idSelf;
345343
x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME;
346344
backofficeWriteLease(&x);
347345
db_end_transaction(0);
348346
if( g.fAnyTrace ){
349
- fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid());
347
+ fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", GETPID());
350348
}
351349
if( x.tmCurrent >= tmNow ){
352350
if( backofficeSleep(1000*(x.tmCurrent - tmNow + 1)) ){
353351
/* The sleep was interrupted by a signal from another thread. */
354352
if( g.fAnyTrace ){
355
- fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid());
353
+ fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID());
356354
}
357355
db_end_transaction(0);
358356
break;
359357
}
360358
}else{
@@ -366,11 +364,11 @@
366364
warningDelay *= 2;
367365
}
368366
if( backofficeSleep(1000) ){
369367
/* The sleep was interrupted by a signal from another thread. */
370368
if( g.fAnyTrace ){
371
- fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", getpid());
369
+ fprintf(stderr, "/***** Backoffice Interrupt %d *****/\n", GETPID());
372370
}
373371
db_end_transaction(0);
374372
break;
375373
}
376374
}
377375
--- 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

Keyboard Shortcuts

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