aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmdsclient/proto-util.c5
1 files 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;
}