]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
sched.c: Make not return a sched id of 0. 35/1735/2
authorRichard Mudgett <rmudgett@digium.com>
Mon, 30 Nov 2015 22:42:47 +0000 (16:42 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 1 Dec 2015 19:45:39 +0000 (13:45 -0600)
According to the API doxygen a sched ID of 0 is valid.  Unfortunately, 0
was never returned historically and several users incorrectly coded usage
of the returned sched ID assuming that 0 was invalid.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20

main/sched.c

index 4b52456c8afe9ea55ac630359cf3c2a791253923..0d3a79819391de33d1bdfe73b7b802792e1e13bb 100644 (file)
@@ -327,9 +327,16 @@ static int add_ids(struct ast_sched_context *con)
                if (!new_id) {
                        break;
                }
-               new_id->id = i;
+
+               /*
+                * According to the API doxygen a sched ID of 0 is valid.
+                * Unfortunately, 0 was never returned historically and
+                * several users incorrectly coded usage of the returned
+                * sched ID assuming that 0 was invalid.
+                */
+               new_id->id = ++con->id_queue_size;
+
                AST_LIST_INSERT_TAIL(&con->id_queue, new_id, list);
-               ++con->id_queue_size;
        }
 
        return con->id_queue_size - original_size;