Commit 408728e4 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2202] Assert instead of throw

So we don't throw from a destructor. This should never happen anyway.
parent 19430797
......@@ -124,9 +124,7 @@ Mutex::unlock() {
assert(impl_ != NULL);
--impl_->locked_count; // Only in debug mode
const int result = pthread_mutex_unlock(&impl_->mutex);
if (result != 0) {
isc_throw(isc::InvalidOperation, strerror(result));
}
assert(result == 0); // This should never be possible
}
// TODO: Disable in non-debug build
......
......@@ -33,10 +33,11 @@ namespace thread {
///
/// Also, as mutex is a low-level system object, an error might happen at any
/// operation with it. We convert many errors to the isc::InvalidOperation,
/// since the errors usually happen only when used in a wrong way. Any methods,
/// constructors or even destructors in this class can throw. Allocation errors
/// are converted to std::bad_alloc (for example when OS-dependant limit of
/// mutexes is exceeded).
/// since the errors usually happen only when used in a wrong way. Any methods
/// or constructors in this class can throw. Allocation errors are converted
/// to std::bad_alloc (for example when OS-dependant limit of mutexes is
/// exceeded). Some errors which usually mean a programmer error abort the
/// program, since there could be no safe way to recover from them.
///
/// The current interface is somewhat minimalistic. If we ever need more, we
/// can add it later.
......@@ -96,10 +97,6 @@ public:
/// \brief Destructor.
///
/// Unlocks the mutex.
///
/// \throw isc::InvalidOperation when OS reports error. This usually
/// means an attempt to use the mutex in a wrong way (unlocking
/// a mutex belonging to a differen thread).
~Locker() {
if (mutex_ != NULL) {
mutex_->unlock();
......
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