Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
408728e4
Commit
408728e4
authored
Oct 02, 2012
by
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/util/threads/lock.cc
View file @
408728e4
...
...
@@ -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
...
...
src/lib/util/threads/lock.h
View file @
408728e4
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment