omtslug commented on issue #292:
URL: 
https://github.com/apache/logging-log4net/issues/292#issuecomment-4273116348

   I'm looking into this code in v3 Hierarchy.cs, (don't know if it's the stuff 
used but i think so)
   ```
     private Logger? TryCreateLogger(LoggerKey key, ILoggerFactory factory)
     {
       if (!_loggers.TryGetValue(key, out object? node))
       {
         Logger newLogger = CreateLogger(key.Name);
         node = _loggers.GetOrAdd(key, newLogger);
         if (node == newLogger)
         {
           RegisterLogger(newLogger);
         }
       }
   
       if (node is Logger logger)
       {
         return logger;
       }
       [snip]
   ```
   Imagine that we have parallel GetLogger calls being made for the same logger.
   Isn't there a risk that a 'not ready' logger is returned?
   Two threads wants the same logger:
     a, neither of them gets it from _loggers.
     b, both does CreateLogger
     c, one of these gets into _loggers and the second GetOrAdd will 
return the one already in _loggers.
     d, the issue is now that this 'second' thread returns the Logger 
from _loggers but the RegisterLogger hasn't been done yet, 
       it's the work for the first thread which in some 
cases is delayed.
   
   Thoughts/discussion welcome.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to