From 6d9d9d950e84f010ed5f4cd8c77e92e8eb563c0d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Aug 2015 02:35:20 +0200 Subject: fix m bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsclient/proto-util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libmdsclient/proto-util.c b/src/libmdsclient/proto-util.c index 6ab2a9c..b4c580e 100644 --- a/src/libmdsclient/proto-util.c +++ b/src/libmdsclient/proto-util.c @@ -770,11 +770,12 @@ int libmds_next_message_id(uint32_t* restrict message_id, int (*test)(uint32_t message_id, void* data), void* data) { uint32_t id = *message_id; + uint32_t first_test; int r; id = id == UINT32_MAX ? 0 : (id + 1); if (test != NULL) - for (;;) + for (first_test = id;;) { r = test(id, data); if (r < 0) @@ -782,7 +783,7 @@ int libmds_next_message_id(uint32_t* restrict message_id, if (r) break; id = id == UINT32_MAX ? 0 : (id + 1); - if (id == *message_id) + if (id == first_test) return errno = EAGAIN, -1; } -- cgit v1.2.3-70-g09d2