forked from I2P_Developers/i2p.i2p
* Logging: Eliminate LogWriter/LogManager deadlock (thx kytv)
This commit is contained in:
@@ -260,21 +260,24 @@ public class LogManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called periodically by the log writer's thread
|
* Called periodically by the log writer's thread
|
||||||
*
|
* Do not log here, deadlock of LogWriter
|
||||||
*/
|
*/
|
||||||
void rereadConfig() {
|
void rereadConfig() {
|
||||||
// perhaps check modification time
|
// perhaps check modification time
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
//if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Rereading configuration file");
|
// _log.debug("Rereading configuration file");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
File cfgFile = _locationFile;
|
File cfgFile = _locationFile;
|
||||||
if (!cfgFile.exists()) {
|
if (!cfgFile.exists()) {
|
||||||
if (!_alreadyNoticedMissingConfig) {
|
if (!_alreadyNoticedMissingConfig) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
//if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Log file " + _locationFile.getAbsolutePath() + " does not exist");
|
// _log.warn("Log file " + _locationFile.getAbsolutePath() + " does not exist");
|
||||||
_alreadyNoticedMissingConfig = true;
|
_alreadyNoticedMissingConfig = true;
|
||||||
}
|
}
|
||||||
parseConfig(new Properties());
|
parseConfig(new Properties());
|
||||||
@@ -284,10 +287,10 @@ public class LogManager {
|
|||||||
_alreadyNoticedMissingConfig = false;
|
_alreadyNoticedMissingConfig = false;
|
||||||
|
|
||||||
if ((_configLastRead > 0) && (_configLastRead >= cfgFile.lastModified())) {
|
if ((_configLastRead > 0) && (_configLastRead >= cfgFile.lastModified())) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
//if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Short circuiting config read (last read: "
|
// _log.info("Short circuiting config read (last read: "
|
||||||
+ (_context.clock().now() - _configLastRead) + "ms ago, config file modified "
|
// + (_context.clock().now() - _configLastRead) + "ms ago, config file modified "
|
||||||
+ (_context.clock().now() - cfgFile.lastModified()) + "ms ago");
|
// + (_context.clock().now() - cfgFile.lastModified()) + "ms ago");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +305,9 @@ public class LogManager {
|
|||||||
updateLimits();
|
updateLimits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void parseConfig(Properties config) {
|
private void parseConfig(Properties config) {
|
||||||
String fmt = config.getProperty(PROP_FORMAT, DEFAULT_FORMAT);
|
String fmt = config.getProperty(PROP_FORMAT, DEFAULT_FORMAT);
|
||||||
_format = fmt.toCharArray();
|
_format = fmt.toCharArray();
|
||||||
@@ -353,16 +359,22 @@ public class LogManager {
|
|||||||
_consoleBufferSize = DEFAULT_CONSOLEBUFFERSIZE;
|
_consoleBufferSize = DEFAULT_CONSOLEBUFFERSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
//if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Log set to use the base log file as " + _baseLogfilename);
|
// _log.debug("Log set to use the base log file as " + _baseLogfilename);
|
||||||
|
|
||||||
parseLimits(config);
|
parseLimits(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void parseLimits(Properties config) {
|
private void parseLimits(Properties config) {
|
||||||
parseLimits(config, PROP_RECORD_PREFIX);
|
parseLimits(config, PROP_RECORD_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void parseLimits(Properties config, String recordPrefix) {
|
private void parseLimits(Properties config, String recordPrefix) {
|
||||||
_limits.clear();
|
_limits.clear();
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@@ -400,6 +412,7 @@ public class LogManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the date format
|
* Update the date format
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
*
|
*
|
||||||
* @param format null or empty string means use default format for the locale
|
* @param format null or empty string means use default format for the locale
|
||||||
* (with a SHORT date and a MEDIUM time - see DateFormat)
|
* (with a SHORT date and a MEDIUM time - see DateFormat)
|
||||||
@@ -423,7 +436,7 @@ public class LogManager {
|
|||||||
_dateFormat = fmt;
|
_dateFormat = fmt;
|
||||||
return true;
|
return true;
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
getLog(LogManager.class).error("Date format is invalid [" + format + "]", iae);
|
//getLog(LogManager.class).error("Date format is invalid [" + format + "]", iae);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,12 +509,18 @@ public class LogManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void updateLimits() {
|
private void updateLimits() {
|
||||||
for (Log log : _logs.values()) {
|
for (Log log : _logs.values()) {
|
||||||
updateLimit(log);
|
updateLimit(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
*/
|
||||||
private void updateLimit(Log log) {
|
private void updateLimit(Log log) {
|
||||||
List<LogLimit> limits = getLimits(log);
|
List<LogLimit> limits = getLimits(log);
|
||||||
LogLimit max = null;
|
LogLimit max = null;
|
||||||
@@ -527,7 +546,10 @@ public class LogManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return null if no matches */
|
/**
|
||||||
|
* Do not log here, deadlock of LogWriter via rereadConfig().
|
||||||
|
* @return null if no matches
|
||||||
|
*/
|
||||||
private List<LogLimit> getLimits(Log log) {
|
private List<LogLimit> getLimits(Log log) {
|
||||||
ArrayList<LogLimit> limits = null; // new ArrayList(4);
|
ArrayList<LogLimit> limits = null; // new ArrayList(4);
|
||||||
for (LogLimit limit : _limits) {
|
for (LogLimit limit : _limits) {
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
2011-12-23 zzz
|
||||||
|
* Logging: Eliminate LogWriter/LogManager deadlock
|
||||||
|
|
||||||
2011-12-18 zzz
|
2011-12-18 zzz
|
||||||
* Addresses: Add utility toString() methods
|
* Addresses: Add utility toString() methods
|
||||||
* Blocklist: Buffer input to speed lookup
|
* Blocklist: Buffer input to speed lookup
|
||||||
|
@@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 24;
|
public final static long BUILD = 25;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "-rc";
|
public final static String EXTRA = "-rc";
|
||||||
|
Reference in New Issue
Block a user