Commit 1a1430c1 authored by Xavier Thompson's avatar Xavier Thompson

Direct cypclass contention locks to stderr and fix unprotected logging

parent 1f7cf860
...@@ -578,15 +578,15 @@ void CyLock::rlock(const char *context) { ...@@ -578,15 +578,15 @@ void CyLock::rlock(const char *context) {
#else #else
pid_t owner_id = this->owner_id; pid_t owner_id = this->owner_id;
pthread_mutex_lock(&(CyLock::log_guard)); pthread_mutex_lock(&(CyLock::log_guard));
std::cout std::cerr
<< "Data Race between [this] reader #" << caller_id << "Data Race between [this] reader #" << caller_id
<< " and [other] writer #" << owner_id << " and [other] writer #" << owner_id
<< " on lock " << this << std::endl; << " on lock " << this << std::endl;
if (context != NULL) { if (context != NULL) {
std::cout << "In [this] context: " << context << std::endl; std::cerr << "In [this] context: " << context << std::endl;
} }
if (this->owner_context != NULL) { if (this->owner_context != NULL) {
std::cout << "In [other] context: " << this->owner_context << std::endl; std::cerr << "In [other] context: " << this->owner_context << std::endl;
} }
pthread_mutex_unlock(&(CyLock::log_guard)); pthread_mutex_unlock(&(CyLock::log_guard));
#endif #endif
...@@ -676,16 +676,18 @@ void CyLock::wlock(const char *context) { ...@@ -676,16 +676,18 @@ void CyLock::wlock(const char *context) {
} }
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
#else #else
std::cout pthread_mutex_lock(&(CyLock::log_guard));
std::cerr
<< "Data Race between [this] writer #" << caller_id << "Data Race between [this] writer #" << caller_id
<< " and [other] reader #" << owner_id << " and [other] reader #" << owner_id
<< " on lock " << this << std::endl; << " on lock " << this << std::endl;
if (context != NULL) { if (context != NULL) {
std::cout << "In [this] context: " << context << std::endl; std::cerr << "In [this] context: " << context << std::endl;
} }
if (this->owner_context != NULL) { if (this->owner_context != NULL) {
std::cout << "In [other] context: " << this->owner_context << std::endl; std::cerr << "In [other] context: " << this->owner_context << std::endl;
} }
pthread_mutex_unlock(&(CyLock::log_guard));
#endif #endif
} }
...@@ -709,15 +711,15 @@ void CyLock::wlock(const char *context) { ...@@ -709,15 +711,15 @@ void CyLock::wlock(const char *context) {
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
#else #else
pthread_mutex_lock(&(CyLock::log_guard)); pthread_mutex_lock(&(CyLock::log_guard));
std::cout std::cerr
<< "Data Race between [this] writer #" << caller_id << "Data Race between [this] writer #" << caller_id
<< " and [other] writer #" << owner_id << " and [other] writer #" << owner_id
<< " on lock " << this << std::endl; << " on lock " << this << std::endl;
if (context != NULL) { if (context != NULL) {
std::cout << "In [this] context: " << context << std::endl; std::cerr << "In [this] context: " << context << std::endl;
} }
if (this->owner_context != NULL) { if (this->owner_context != NULL) {
std::cout << "In [other] context: " << this->owner_context << std::endl; std::cerr << "In [other] context: " << this->owner_context << std::endl;
} }
pthread_mutex_unlock(&(CyLock::log_guard)); pthread_mutex_unlock(&(CyLock::log_guard));
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment