extern DoutStreambuf <char> *_doss;
// TODO: get rid of this lock using thread-local storage
-extern Mutex _dout_lock;
+extern pthread_mutex_t _dout_lock;
//////////////////////// Helper functions //////////////////////////
// Try a 0-byte write to a file descriptor to see if it open.
template <typename charT, typename traits>
void DoutStreambuf<charT, traits>::handle_stderr_closed()
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
flags &= ~DOUTSB_FLAG_STDERR;
}
template <typename charT, typename traits>
void DoutStreambuf<charT, traits>::read_global_config()
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
flags = 0;
if (ofd != -1) {
template <typename charT, typename traits>
int DoutStreambuf<charT, traits>::handle_pid_change()
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
if (!(flags & DOUTSB_FLAG_OFILE))
return 0;
template <typename charT, typename traits>
int DoutStreambuf<charT, traits>::create_rank_symlink(int n)
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
if (!(flags & DOUTSB_FLAG_OFILE))
return 0;
template <typename charT, typename traits>
std::string DoutStreambuf<charT, traits>::config_to_str() const
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
ostringstream oss;
oss << "g_conf.log_to_stderr = " << g_conf.log_to_stderr << "\n";
oss << "g_conf.log_to_syslog = " << g_conf.log_to_syslog << "\n";
template <typename charT, typename traits>
std::string DoutStreambuf<charT, traits>::_calculate_opath() const
{
- assert(_dout_lock.is_locked());
+ // should hold the dout_lock here
// If g_conf.log_file was specified, that takes the highest priority
if (!empty(g_conf.log_file)) {
/*
* The dout lock protects calls to dout()
- *
- * By using an early init_priority, we ensure that the dout lock is
- * initialized first and destroyed last.
*/
-Mutex _dout_lock __attribute__((init_priority(110)))
- ("_dout_lock", false, false /* no lockdep */);
+pthread_mutex_t _dout_lock = PTHREAD_MUTEX_INITIALIZER;
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
void _dout_open_log(bool print_version)
{
- assert(_dout_lock.is_locked());
+ // should hold _dout_lock here
if (!_doss) {
_doss = new DoutStreambuf <char>();
extern std::ostream *_dout;
extern DoutStreambuf <char> *_doss;
extern bool _dout_need_open;
-extern Mutex _dout_lock;
+extern pthread_mutex_t _dout_lock;
extern void _dout_open_log(bool print_version);
{
public:
DoutLocker() {
- _dout_lock.Lock();
+ pthread_mutex_lock(&_dout_lock);
}
~DoutLocker() {
- _dout_lock.Unlock();
+ pthread_mutex_unlock(&_dout_lock);
}
};