]> git.ipfire.org Git - thirdparty/suricata.git/commit
radix: don't modify node prefix on lookup
authorVictor Julien <victor@inliniac.net>
Fri, 20 Dec 2013 13:19:23 +0000 (14:19 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 7 Feb 2014 16:16:14 +0000 (17:16 +0100)
commit7b4be598c46da33b0fb4addf949ebb8aa7e8ab8a
treeb4f93ea859df6b9e931e8bb77fdd079911b18d53
parent7a9da787f9151d8a919c73ca25dfb66b353e1b20
radix: don't modify node prefix on lookup

The radix tree stores user data. However, it had no function to return
this data to the consumers of the API. Instead, on lookup, it would
set a field "user_data_result" in the nodes prefix structure which
could then be read by the caller.

Apart for this not being a very nice design as it exposes API internals
to the caller, it is not thread safe. By updating the global data
structure without any form (or suggestion) of locking, threads could
overwrite the same field unexpectedly.

This patch modifies the lookup logic to get rid of this stored
user_data_result. Instead, all the lookup functions how take an
addition argument: void **user_data_result.

Through this pointer the user data is returned. It's allowed to be
NULL, in this case the user data is ignored.

This is a significant API change, that affects a lot of tests and
callers. These will be updated in follow up patches.

Bug #1073.
src/util-radix-tree.c
src/util-radix-tree.h