Log::Log(SubsystemMap *s)
: m_indirect_this(NULL),
m_subs(s),
+ m_queue_mutex_holder(0),
+ m_flush_mutex_holder(0),
m_new(), m_recent(),
m_fd(-1),
m_syslog_log(-2), m_syslog_crash(-2),
void Log::submit_entry(Entry *e)
{
pthread_mutex_lock(&m_queue_mutex);
+ m_queue_mutex_holder = pthread_self();
// wait for flush to catch up
while (m_new.m_len > m_max_new)
m_new.enqueue(e);
pthread_cond_signal(&m_cond_flusher);
+ m_queue_mutex_holder = 0;
pthread_mutex_unlock(&m_queue_mutex);
}
void Log::flush()
{
pthread_mutex_lock(&m_flush_mutex);
+ m_flush_mutex_holder = pthread_self();
pthread_mutex_lock(&m_queue_mutex);
+ m_queue_mutex_holder = pthread_self();
EntryQueue t;
t.swap(m_new);
pthread_cond_broadcast(&m_cond_loggers);
+ m_queue_mutex_holder = 0;
pthread_mutex_unlock(&m_queue_mutex);
_flush(&t, &m_recent, false);
delete m_recent.dequeue();
}
+ m_flush_mutex_holder = 0;
pthread_mutex_unlock(&m_flush_mutex);
}
void Log::dump_recent()
{
pthread_mutex_lock(&m_flush_mutex);
+ m_flush_mutex_holder = pthread_self();
pthread_mutex_lock(&m_queue_mutex);
+ m_queue_mutex_holder = pthread_self();
+
EntryQueue t;
t.swap(m_new);
+
+ m_queue_mutex_holder = 0;
pthread_mutex_unlock(&m_queue_mutex);
_flush(&t, &m_recent, false);
_log_message("--- end dump of recent events ---", true);
+ m_flush_mutex_holder = 0;
pthread_mutex_unlock(&m_flush_mutex);
}
void *Log::entry()
{
pthread_mutex_lock(&m_queue_mutex);
+ m_queue_mutex_holder = pthread_self();
while (!m_stop) {
if (!m_new.empty()) {
+ m_queue_mutex_holder = 0;
pthread_mutex_unlock(&m_queue_mutex);
flush();
pthread_mutex_lock(&m_queue_mutex);
+ m_queue_mutex_holder = pthread_self();
continue;
}
pthread_cond_wait(&m_cond_flusher, &m_queue_mutex);
}
+ m_queue_mutex_holder = 0;
pthread_mutex_unlock(&m_queue_mutex);
flush();
return NULL;
}
+bool Log::is_inside_log_lock()
+{
+ return
+ pthread_self() == m_queue_mutex_holder ||
+ pthread_self() == m_flush_mutex_holder;
+}
+
} // ceph::log::
} // ceph::