Ignore:
Timestamp:
Nov 30, 2011, 2:58:20 PM (14 years ago)
Author:
dmik
Message:

Use pid instead of the ordinal number in log file names.

This in particular fixes the problem when WGSS50 writes to the log
before the ordinal is correctly initialized by KERNEL32 which resulted
into two processes writing to the same log file.

This also guarantees that a subsequent re-run will not vanish the
previous log file which is also useful sometimes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/kernel32/dbglog.cpp

    r21790 r21837  
    2626#include <string.h>
    2727#include <stdarg.h>
     28#include <process.h>
    2829#include <win32type.h>
    2930#include <win32api.h>
     
    332333#ifdef WIN32_IP_LOGGING
    333334        char *logserver = getenv("WIN32LOG_IPSERVER");
    334         if(logserver && loadNr == 0) {
     335        if(logserver) {
    335336             sock_init();
    336337
     
    348349            pszLogBase = "odin32_";
    349350
    350         sprintf(szLogFile, "%s%d.log", pszLogBase, loadNr);
     351        sprintf(szLogFile, "%s%d.log", pszLogBase, getpid());
    351352        flog = fopen(szLogFile, "w");
    352353        if(flog == NULL)
    353354        {//probably running exe on readonly device
    354             sprintf(szLogFile, "%sodin32_%d.log", kernel32Path, loadNr);
     355            sprintf(szLogFile, "%sodin32_%d.log", kernel32Path, getpid());
    355356            flog = fopen(szLogFile, "w");
    356357        }
     
    576577        char logname[CCHMAXPATH];
    577578
    578         sprintf(logname, "odin32_%d.log", loadNr);
     579        sprintf(logname, "odin32_%d.log", getpid());
    579580        flog = fopen(logname, "w");
    580581        if(flog == NULL) {//probably running exe on readonly device
    581             sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
     582            sprintf(logname, "%sodin32_%d.log", kernel32Path, getpid());
    582583            flog = fopen(logname, "w");
    583584        }
Note: See TracChangeset for help on using the changeset viewer.