summaryrefslogtreecommitdiff
path: root/toxcore/util.c
diff options
context:
space:
mode:
authorzugz <mbays+tox@sdf.org>2017-01-19 18:51:14 +0100
committerzugz <mbays+tox@sdf.org>2017-01-21 22:08:52 +0100
commitb630121f2f659027e1c9f00cd97087ef34e95677 (patch)
tree7972d498fa05b0955c684c83b79bf12000cb7cf2 /toxcore/util.c
parentf185834e9afe83a2bb06e015a3e41b4ac97b48c3 (diff)
reduce thread-unsafe use of static variables
- rework ip_ntoa() to avoid use of static variables - rework sort_client_list() to avoid use of static variables - move static 'lastdump' into Messenger struct - rework ID2String() to avoid use of static variables; rename to id_to_string() - fetch_broadcast_info(): attempt to mitigate risks from concurrent execution - current_time_monotonic(): attempt to mitigate risks from concurrent execution - comment on non-thread-safety of unix_time_update
Diffstat (limited to 'toxcore/util.c')
-rw-r--r--toxcore/util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/toxcore/util.c b/toxcore/util.c
index e1bbf4db..22fa0fc9 100644
--- a/toxcore/util.c
+++ b/toxcore/util.c
@@ -41,6 +41,8 @@
41static uint64_t unix_time_value; 41static uint64_t unix_time_value;
42static uint64_t unix_base_time_value; 42static uint64_t unix_base_time_value;
43 43
44/* XXX: note that this is not thread-safe; if multiple threads call unix_time_update() concurrently, the return value of
45 * unix_time() may fail to increase monotonically with increasing time */
44void unix_time_update(void) 46void unix_time_update(void)
45{ 47{
46 if (unix_base_time_value == 0) { 48 if (unix_base_time_value == 0) {