resource-asm: keep the handles below maximum.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 12 Apr 2013 09:06:08 +0000 (12:06 +0300)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Thu, 8 Jan 2015 16:37:09 +0000 (18:37 +0200)
src/plugins/plugin-resource-asm.c

index ea91433..fbdcecc 100644 (file)
@@ -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)