Fossil SCM
In the backoffice module, use GETPID macro consistently, fix compiler warning with MinGW, and add an assert().
Commit
af87fa5bcd93e318c507b145b8c09e222cb6d88fe0f1d377cd3a3aa0af06ab2d
Parent
014bb2d7debc98e…
1 file changed
+8
-4
+8
-4
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -62,10 +62,13 @@ | ||
| 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 | |
| 67 | 70 | # define GETPID (int)GetCurrentProcessId |
| 68 | 71 | #else |
| 69 | 72 | # include <unistd.h> |
| 70 | 73 | # include <sys/types.h> |
| 71 | 74 | # include <signal.h> |
| @@ -477,10 +480,11 @@ | ||
| 477 | 480 | break; |
| 478 | 481 | } |
| 479 | 482 | } |
| 480 | 483 | } |
| 481 | 484 | #if defined(_WIN32) |
| 485 | + assert( threadHandle!=NULL ); | |
| 482 | 486 | backofficeWin32ThreadCleanup(); |
| 483 | 487 | #endif |
| 484 | 488 | return; |
| 485 | 489 | } |
| 486 | 490 | |
| @@ -495,11 +499,11 @@ | ||
| 495 | 499 | char *zLog = db_get("backoffice-logfile",0); |
| 496 | 500 | if( zLog && zLog[0] ){ |
| 497 | 501 | FILE *pLog = fossil_fopen(zLog, "a"); |
| 498 | 502 | if( pLog ){ |
| 499 | 503 | 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()); | |
| 501 | 505 | fclose(pLog); |
| 502 | 506 | } |
| 503 | 507 | } |
| 504 | 508 | |
| 505 | 509 | /* Here is where the actual work of the backoffice happens */ |
| @@ -546,11 +550,11 @@ | ||
| 546 | 550 | x = _wspawnv(_P_NOWAIT, ax[0], ax); |
| 547 | 551 | for(i=0; i<=3; i++) fossil_unicode_free(ax[i]); |
| 548 | 552 | if( g.fAnyTrace ){ |
| 549 | 553 | fprintf(stderr, |
| 550 | 554 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 551 | - getpid(), (int)x); | |
| 555 | + GETPID(), (int)x); | |
| 552 | 556 | } |
| 553 | 557 | if( x>=0 ) return; |
| 554 | 558 | } |
| 555 | 559 | #else /* unix */ |
| 556 | 560 | { |
| @@ -558,11 +562,11 @@ | ||
| 558 | 562 | if( pid>0 ){ |
| 559 | 563 | /* This is the parent in a successful fork(). Return immediately. */ |
| 560 | 564 | if( g.fAnyTrace ){ |
| 561 | 565 | fprintf(stderr, |
| 562 | 566 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 563 | - getpid(), (int)pid); | |
| 567 | + GETPID(), (int)pid); | |
| 564 | 568 | } |
| 565 | 569 | return; |
| 566 | 570 | } |
| 567 | 571 | if( pid==0 ){ |
| 568 | 572 | /* This is the child of a successful fork(). Run backoffice. */ |
| @@ -570,11 +574,11 @@ | ||
| 570 | 574 | db_open_repository(backofficeDb); |
| 571 | 575 | backofficeDb = "x"; |
| 572 | 576 | backoffice_thread(); |
| 573 | 577 | db_close(1); |
| 574 | 578 | if( g.fAnyTrace ){ |
| 575 | - fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", getpid()); | |
| 579 | + fprintf(stderr, "/***** Backoffice Child %d exits *****/\n", GETPID()); | |
| 576 | 580 | } |
| 577 | 581 | exit(0); |
| 578 | 582 | } |
| 579 | 583 | } |
| 580 | 584 | #endif |
| 581 | 585 |
| --- 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 |