Skip to content
Snippets Groups Projects
Commit 0b115178 authored by Utz-Uwe Haus's avatar Utz-Uwe Haus
Browse files

improve cond_timedwait reporting in cleanup_waitup

parent 7da0c636
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,7 @@
#include <stdatomic.h>
#include <stdint.h>
#include <pthread.h>
#include <errno.h>
/* how much (in sec) are we willing to wait for generic table to be cleared */
......@@ -60,6 +61,7 @@
/** Generic timed wait on hash table proper cleanup
**/
/* this should really be a function, not a macro, but HTABLE_COUNT does not take generic args */
#define mstro_cleanup_waitup(retstat,htable,lock,cond,reason) { \
retstat = MSTRO_OK; \
do { \
......@@ -78,16 +80,23 @@
} \
\
unsigned rem_ = HASH_COUNT(htable); \
if(!rem_) { \
if(rem_==0) { \
INFO("All items in `%s` already completed cleanly\n", reason); \
} else { \
INFO("In `%s`, %d item(s) still pending, waiting up to %d sec\n",\
reason, rem_, MSTRO_TIMED_WAIT); \
while (HASH_COUNT(htable) && !rc_) \
do { \
rc_ = pthread_cond_timedwait(cond, lock, &ts); \
} while (!rc_ && HASH_COUNT(htable)>0 ); \
\
if(rc_!=0) { \
if(rc_==ETIMEDOUT) { \
ERR("Waited %zu seconds without change to table\n", \
(uint64_t)MSTRO_TIMED_WAIT); \
} else { \
ERR("Failed to perform timedwait: %d (%s)\n", \
rc_, strerror(rc_)); \
} \
retstat = MSTRO_FAIL; \
break; \
} \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment