CA-407313: Replace semaphore & spinlock with rwlock#26
CA-407313: Replace semaphore & spinlock with rwlock#26GeraldEV merged 6 commits intoxenserver:masterfrom
Conversation
rwlock decreases the amount of blocking for logging by separating the locking for logging to thread safe stdio versus thread unsafe operations such as reopening files. Use flockfile/funlockfile to ensure contiguous log messages where needed. Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
don't hold the rwlock during syslogging (except for the wrlock during reopen) release the lock before syslogging Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
| pthread_spin_destroy(&lock); | ||
| #endif | ||
| pthread_rwlock_unlock(&lock); | ||
| pthread_rwlock_destroy(&lock); |
There was a problem hiding this comment.
I haven't checked the order of cleanup/termination, but destroying the lock can be problematic if other threads try to use it afterwards. I realized that the previous code did this too...
There was a problem hiding this comment.
I'll investigate the clean up order to determine if this can safely be destroyed here
There was a problem hiding this comment.
log_terminate is used once when the threads haven't been setup yet (e.g. if a license check fails), and again after the clean up once each of the threads have been terminated
Therefore destroying the lock during log_terminate is safe
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
| // | ||
|
|
||
| va_start(ap, fmt); | ||
| vfprintf(fpLogfile, fmt, ap); |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
| // | ||
|
|
||
| va_start(ap, fmt); | ||
| vfprintf(fpLogfile, fmt, ap); |
Check warning
Code scanning / CodeChecker
format string is not a string literal Warning
|
|
||
| // | ||
| // We don't use fsync(). See comments in log_message(). | ||
| // |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
| // | ||
| // fsync(fileno(fpLogfile)); | ||
| // | ||
| } |
Check warning
Code scanning / CodeChecker
the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
rwlock decreases the amount of blocking for logging by separating the
locking for logging to thread safe stdio versus thread unsafe
operations such as reopening files.
Use flockfile/funlockfile to ensure contiguous log messages where
needed.
Signed-off-by: Gerald Elder-Vass gerald.elder-vass@cloud.com
Tested on a pool which previously had HA enabled; disabled HA, updated xha, re-enabled HA and monitored the pool for a while (and some operations to spark some logging)