Ignore:
Timestamp:
Jan 2, 2000, 11:09:02 PM (26 years ago)
Author:
sandervl
Message:

Fixed Odin zombie processes when there's a trap inside vfprintf during logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/misc.cpp

    r2061 r2298  
    1 /* $Id: misc.cpp,v 1.15 1999-12-12 14:32:38 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.16 2000-01-02 22:09:01 sandervl Exp $ */
    22
    33/*
     
    2929#include "initterm.h"
    3030#include "logging.h"
     31#include <wprocess.h>
    3132
    3233/*****************************************************************************
     
    273274  if(fLogging && flog)
    274275  {
     276    THDB *thdb = GetThreadTHDB();
     277
    275278    va_start(argptr, tekst);
     279    if(thdb) thdb->logfile = (DWORD)flog;
    276280    vfprintf(flog, tekst, argptr);
     281    if(thdb) thdb->logfile = 0;
    277282    va_end(argptr);
    278283
     
    280285      fprintf(flog, "\n");
    281286  }
    282 
     287  fflush(flog);
    283288  SetFS(sel);
    284289  return 1;
     
    293298  if(fLogging && logfile)
    294299  {
     300    THDB *thdb = GetThreadTHDB();
     301
    295302    va_start(argptr, tekst);
     303    if(thdb) thdb->logfile = (DWORD)logfile;
    296304    vfprintf((FILE *)logfile, tekst, argptr);
     305    if(thdb) thdb->logfile = 0;
    297306    va_end(argptr);
    298307
     
    303312  SetFS(sel);
    304313  return 1;
     314}
     315//******************************************************************************
     316//Check if the exception occurred inside a fprintf (logging THDB member set)
     317//If true, decrease the lock count for that file stream
     318//NOTE: HACK: DEPENDS ON COMPILER VERSION!!!!
     319//******************************************************************************
     320void CheckLogException()
     321{
     322  THDB *thdb = GetThreadTHDB();
     323  USHORT *lock;
     324
     325  if(!thdb) return;
     326
     327  if(thdb->logfile) {
     328        //oops, exception in vfprintf; let's clear the lock count
     329#if (__IBMCPP__ == 300) || (__IBMC__ == 300)
     330        lock = (USHORT *)(thdb->logfile+0x1C);
     331#else
     332#error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
     333#endif
     334        (*lock)--;
     335  }
    305336}
    306337//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.