From bc5ed652b1fe5cf210feec21226ede3e21882b45 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 19 Feb 2012 12:51:09 +0100 Subject: [PATCH] AMQP plugin: Support sub-second sleep intervals. Change-Id: I9afcd8d17f1251b0765dfbdae5ed8581b73b15fe --- src/amqp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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; } -- 2.11.0