]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
ringlogger: document races
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 18 Mar 2019 18:49:25 +0000 (12:49 -0600)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 18 Mar 2019 18:50:00 +0000 (12:50 -0600)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/Shared/Logging/ringlogger.c

index 440a269fa770b27aeced0e138ce5c77f771666fe..563483a4a5c880965f35a647ae07e801bf9c99a6 100644 (file)
@@ -42,11 +42,14 @@ void write_msg_to_log(struct log *log, const char *tag, const char *msg)
        struct log_line *line;
        struct timespec ts;
 
+       // Race: This isn't synchronized with the fetch_add below, so items might be slightly out of order.
        clock_gettime(CLOCK_REALTIME, &ts);
 
+       // Race: More than MAX_LINES writers and this will clash.
        index = atomic_fetch_add(&log->next_index, 1);
        line = &log->lines[index % MAX_LINES];
 
+       // Race: Before this line executes, we'll display old data after new data.
        atomic_store(&line->time_ns, 0);
        memset(line->line, 0, MAX_LOG_LINE_LENGTH);