Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8275083

Fold two locks into one for LogFileOutput

XMLWordPrintable

    • 18
    • generic
    • generic

      Currently, each write of LogFileOutput requires two locks.

      First, current thread holds _rotation_semaphore(1), which is used to protect log rotation. Secondly, current thread will call flockfile(_stream) to ensure multiple threads won't interleave FILE* _stream.

      The second one is redundant for LogFileOutput because _rotate_semaphore prevents other threads from writing _stream.

      Not only it's slow, but it's also easy to end up with deadlock.
      I think we should use a semaphore to fold two locks into one. flockfile doesn't work for log rotation scenrio because fclose() in LogFileOutput::rotate() will automatically unlock FILE->_lock.


            xliu Xin Liu
            xliu Xin Liu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: