summaryrefslogtreecommitdiff
path: root/libgpsd_core.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-01-30 18:18:19 -0800
committerGary E. Miller <gem@rellim.com>2015-01-30 18:18:19 -0800
commit9e13957b3d9c9717ca8d5ee2a7ee5388bcce31ac (patch)
treecc35dfe73aa2c5a795dc22aecbe5e731871ed85e /libgpsd_core.c
parentedb929e131e41ee8ebf9683d042f649a4298e7ee (diff)
downloadgpsd-9e13957b3d9c9717ca8d5ee2a7ee5388bcce31ac.tar.gz
Document why gpsd needs to die on certain mutex failures.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r--libgpsd_core.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 726e6976..579d32e1 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -67,6 +67,10 @@ void gpsd_acquire_reporting_lock(void)
err = pthread_mutex_lock(&report_mutex);
/*@ +unrecog @*/
if ( 0 != err ) {
+ /* POSIX says pthread_mutex_lock() should only fail if the
+ thread holding the lock has died. Best for gppsd to just die
+ because things are FUBAR. */
+
(void) fprintf(stderr,"pthread_mutex_lock() failed: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
@@ -80,6 +84,11 @@ void gpsd_release_reporting_lock(void)
err = pthread_mutex_unlock(&report_mutex);
/*@ +unrecog @*/
if ( 0 != err ) {
+ /* POSIX says pthread_mutex_unlock() should only fail when
+ trying to unlock a lock that does not exist, or is not owned by
+ this thread. This should never happen, so best for gpsd to die
+ because things are FUBAR. */
+
(void) fprintf(stderr,"pthread_mutex_unlock() failed: %s\n",
strerror(errno));
exit(EXIT_FAILURE);