summaryrefslogtreecommitdiffstats
path: root/libdimension/progress.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/progress.c')
-rw-r--r--libdimension/progress.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/libdimension/progress.c b/libdimension/progress.c
index aeac2ac..f7a8b62 100644
--- a/libdimension/progress.c
+++ b/libdimension/progress.c
@@ -65,29 +65,6 @@ dmnsn_new_progress()
return progress;
}
-/* Delete a dmnsn_progress*, which has not yet been associated with a thread */
-void
-dmnsn_delete_progress(dmnsn_progress *progress)
-{
- if (progress) {
- if (pthread_rwlock_destroy(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking rwlock.");
- }
- if (pthread_mutex_destroy(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking mutex.");
- }
- if (pthread_cond_destroy(progress->cond) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
- }
-
- dmnsn_free(progress->rwlock);
- dmnsn_free(progress->mutex);
- dmnsn_free(progress->cond);
- dmnsn_delete_array(progress->elements);
- dmnsn_free(progress);
- }
-}
-
/* Join the worker thread and delete `progress'. */
int
dmnsn_finish_progress(dmnsn_progress *progress)
@@ -96,6 +73,7 @@ dmnsn_finish_progress(dmnsn_progress *progress)
int retval = -1;
if (progress) {
+ /* Get the thread's return value */
if (pthread_join(progress->thread, &ptr) != 0) {
/* Medium severity because an unjoined thread likely means that the thread
is incomplete or invalid */
@@ -103,10 +81,23 @@ dmnsn_finish_progress(dmnsn_progress *progress)
} else if (ptr) {
retval = *(int *)ptr;
dmnsn_free(ptr);
- /* Wake up all waiters */
- dmnsn_done_progress(progress);
}
- dmnsn_delete_progress(progress);
+
+ /* Free the progress object */
+ if (pthread_rwlock_destroy(progress->rwlock) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking rwlock.");
+ }
+ if (pthread_mutex_destroy(progress->mutex) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking mutex.");
+ }
+ if (pthread_cond_destroy(progress->cond) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
+ }
+ dmnsn_free(progress->rwlock);
+ dmnsn_free(progress->mutex);
+ dmnsn_free(progress->cond);
+ dmnsn_delete_array(progress->elements);
+ dmnsn_free(progress);
}
return retval;