From 84ccc5c41075fac412c8f566a511856bdfb4a866 Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Fri, 12 Apr 2013 12:06:08 +0300 Subject: [PATCH] resource-asm: keep the handles below maximum. --- src/plugins/plugin-resource-asm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin-resource-asm.c b/src/plugins/plugin-resource-asm.c index ea91433..fbdcecc 100644 --- a/src/plugins/plugin-resource-asm.c +++ b/src/plugins/plugin-resource-asm.c @@ -612,6 +612,20 @@ static uint32_t get_handle(uint32_t data) { } #endif + +static uint32_t get_next_handle(client_t *client) +{ + uint32_t retval = client->current_handle; + + client->current_handle++; + + if (client->current_handle == ASM_SERVER_HANDLE_MAX) + client->current_handle = 1; + + return retval; +} + + static void htbl_free_client_class(void *key, void *object) { client_class_t *client_class = (client_class_t *) object; @@ -996,7 +1010,7 @@ static asm_to_lib_t *process_msg(lib_to_asm_t *msg, asm_data_t *ctx) goto error; } - handle = client->current_handle++; + handle = get_next_handle(client); d = (resource_set_data_t *) mrp_allocz(sizeof(resource_set_data_t)); if (!d) -- 2.7.4