Fossil SCM

In the backoffice module, use GETPID macro consistently, fix compiler warning with MinGW, and add an assert().

mistachkin 2018-08-07 21:45 trunk
Commit af87fa5bcd93e318c507b145b8c09e222cb6d88fe0f1d377cd3a3aa0af06ab2d
1 file changed +8 -4
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,10 +62,13 @@
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
6770
# define GETPID (int)GetCurrentProcessId
6871
#else
6972
# include <unistd.h>
7073
# include <sys/types.h>
7174
# include <signal.h>
@@ -477,10 +480,11 @@
477480
break;
478481
}
479482
}
480483
}
481484
#if defined(_WIN32)
485
+ assert( threadHandle!=NULL );
482486
backofficeWin32ThreadCleanup();
483487
#endif
484488
return;
485489
}
486490
@@ -495,11 +499,11 @@
495499
char *zLog = db_get("backoffice-logfile",0);
496500
if( zLog && zLog[0] ){
497501
FILE *pLog = fossil_fopen(zLog, "a");
498502
if( pLog ){
499503
char *zDate = db_text(0, "SELECT datetime('now');");
500
- fprintf(pLog, "%s (%d) backoffice running\n", zDate, getpid());
504
+ fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
501505
fclose(pLog);
502506
}
503507
}
504508
505509
/* Here is where the actual work of the backoffice happens */
@@ -546,11 +550,11 @@
546550
x = _wspawnv(_P_NOWAIT, ax[0], ax);
547551
for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);
548552
if( g.fAnyTrace ){
549553
fprintf(stderr,
550554
"/***** Subprocess %d creates backoffice child %d *****/\n",
551
- getpid(), (int)x);
555
+ GETPID(), (int)x);
552556
}
553557
if( x>=0 ) return;
554558
}
555559
#else /* unix */
556560
{
@@ -558,11 +562,11 @@
558562
if( pid>0 ){
559563
/* This is the parent in a successful fork(). Return immediately. */
560564
if( g.fAnyTrace ){
561565
fprintf(stderr,
562566
"/***** Subprocess %d creates backoffice child %d *****/\n",
563
- getpid(), (int)pid);
567
+ GETPID(), (int)pid);
564568
}
565569
return;
566570
}
567571
if( pid==0 ){
568572
/* This is the child of a successful fork(). Run backoffice. */
@@ -570,11 +574,11 @@
570574
db_open_repository(backofficeDb);
571575
backofficeDb = "x";
572576
backoffice_thread();
573577
db_close(1);
574578
if( g.fAnyTrace ){
575
- fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid());
579
+ fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID());
576580
}
577581
exit(0);
578582
}
579583
}
580584
#endif
581585
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,10 +62,13 @@
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>
@@ -477,10 +480,11 @@
477 break;
478 }
479 }
480 }
481 #if defined(_WIN32)
 
482 backofficeWin32ThreadCleanup();
483 #endif
484 return;
485 }
486
@@ -495,11 +499,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 */
@@ -546,11 +550,11 @@
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 {
@@ -558,11 +562,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. */
@@ -570,11 +574,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
--- src/backoffice.c
+++ src/backoffice.c
@@ -62,10 +62,13 @@
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>
@@ -477,10 +480,11 @@
480 break;
481 }
482 }
483 }
484 #if defined(_WIN32)
485 assert( threadHandle!=NULL );
486 backofficeWin32ThreadCleanup();
487 #endif
488 return;
489 }
490
@@ -495,11 +499,11 @@
499 char *zLog = db_get("backoffice-logfile",0);
500 if( zLog && zLog[0] ){
501 FILE *pLog = fossil_fopen(zLog, "a");
502 if( pLog ){
503 char *zDate = db_text(0, "SELECT datetime('now');");
504 fprintf(pLog, "%s (%d) backoffice running\n", zDate, GETPID());
505 fclose(pLog);
506 }
507 }
508
509 /* Here is where the actual work of the backoffice happens */
@@ -546,11 +550,11 @@
550 x = _wspawnv(_P_NOWAIT, ax[0], ax);
551 for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);
552 if( g.fAnyTrace ){
553 fprintf(stderr,
554 "/***** Subprocess %d creates backoffice child %d *****/\n",
555 GETPID(), (int)x);
556 }
557 if( x>=0 ) return;
558 }
559 #else /* unix */
560 {
@@ -558,11 +562,11 @@
562 if( pid>0 ){
563 /* This is the parent in a successful fork(). Return immediately. */
564 if( g.fAnyTrace ){
565 fprintf(stderr,
566 "/***** Subprocess %d creates backoffice child %d *****/\n",
567 GETPID(), (int)pid);
568 }
569 return;
570 }
571 if( pid==0 ){
572 /* This is the child of a successful fork(). Run backoffice. */
@@ -570,11 +574,11 @@
574 db_open_repository(backofficeDb);
575 backofficeDb = "x";
576 backoffice_thread();
577 db_close(1);
578 if( g.fAnyTrace ){
579 fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID());
580 }
581 exit(0);
582 }
583 }
584 #endif
585

Keyboard Shortcuts

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