nbr_table_register: make sure not to register a given table twice

This commit is contained in:
Simon Duquennoy 2018-03-19 12:09:07 -07:00
parent baa02a76f2
commit eb62a7894c
1 changed files with 7 additions and 0 deletions

View File

@ -290,6 +290,13 @@ nbr_table_register(nbr_table_t *table, nbr_table_callback *callback)
ctimer_set(&periodic_timer, CLOCK_SECOND * 60, handle_periodic_timer, NULL);
}
#endif
if(nbr_table_is_registered(table)) {
/* Table already registered, just update callback */
table->callback = callback;
return 1;
}
if(num_tables < MAX_NUM_TABLES) {
table->index = num_tables++;
table->callback = callback;