From: Florian Forster Date: Sun, 19 Feb 2012 11:51:09 +0000 (+0100) Subject: AMQP plugin: Support sub-second sleep intervals. X-Git-Tag: collectd-5.0.4~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bc5ed652b1fe5cf210feec21226ede3e21882b45;p=collectd.git AMQP plugin: Support sub-second sleep intervals. Change-Id: I9afcd8d17f1251b0765dfbdae5ed8581b73b15fe --- diff --git a/src/amqp.c b/src/amqp.c index 55eba670..be1f709e 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -550,21 +550,25 @@ static void *camqp_subscribe_thread (void *user_data) /* {{{ */ status = camqp_connect (conf); if (status != 0) { + struct timespec ts_interval; ERROR ("amqp plugin: camqp_connect failed. " - "Will sleep for %u seconds.", - (unsigned int) CDTIME_T_TO_TIME_T (interval_g)); - sleep ((unsigned int) CDTIME_T_TO_TIME_T (interval_g)); + "Will sleep for %.3f seconds.", + CDTIME_T_TO_DOUBLE (interval_g)); + CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval); + nanosleep (&ts_interval, /* remaining = */ NULL); continue; } status = amqp_simple_wait_frame (conf->connection, &frame); if (status < 0) { + struct timespec ts_interval; ERROR ("amqp plugin: amqp_simple_wait_frame failed. " - "Will sleep for %u seconds.", - (unsigned int) CDTIME_T_TO_TIME_T (interval_g)); + "Will sleep for %.3f seconds.", + CDTIME_T_TO_DOUBLE (interval_g)); camqp_close_connection (conf); - sleep ((unsigned int) CDTIME_T_TO_TIME_T (interval_g)); + CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval); + nanosleep (&ts_interval, /* remaining = */ NULL); continue; }