Branch: Tag:

2012-06-08

2012-06-08 14:08:52 by Martin Stjernholm <mast@lysator.liu.se>

Fixed race when stopping LogFile instances.

Replaced the approach from rev 1.1068, which didn't really help anything
since there's no destroy() that locks the mutex (and there better not be).

Rev: server/base_server/configuration.pike:1.727
Rev: server/base_server/roxen.pike:1.1115
Rev: server/modules/logging/memory_logger.pike:1.5

5:   // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.726 2012/05/10 17:48:29 mast Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.727 2012/06/08 14:08:52 mast Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>
689:    STOP_MODULES (indices (p->provider_modules), "provider module");    }    -  if (mixed err = catch { -  if (object m = log_function && function_object (log_function)) { -  destruct (m); -  allmods[m] = 0; -  } -  }) report_error ("While stopping the logger: " + describe_backtrace (err)); +  end_logger();       STOP_MODULES(indices (allmods), "unclassified module");   #undef STOP_MODULES
1060:    return filter_module_cache;   }    -  - void init_log_file() + void end_logger()   { -  if(log_function) -  { -  // Free the old one. -  destruct(function_object(log_function)); +  if (mixed err = catch { +  if (roxen.LogFile logger = +  log_function && function_object (log_function)) { +  logger->close(); +  destruct (logger); +  } +  }) report_error ("While stopping the logger: " + describe_backtrace (err));    log_function = 0;   } -  +  + void init_log_file() + { +  end_logger();    // Only try to open the log file if logging is enabled!!    if(query("Log"))    {