Skip to content

Commit

Permalink
Fix: DirSink could drop logs if the mutex was locked while logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
raldone01 committed Jun 6, 2024
1 parent 03550b8 commit 582a0a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion funcs/logger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ class DirSink extends LogSink:
_io_thread_current_file.close()

func write_bulks(p_log_records: Array[Dictionary], p_formatted_messages: PackedStringArray) -> void:
if _io_thread_log_lock.try_lock():
# If this causes lag spikes this can be replaced with a try_lock but a second buffer is needed to avoid dropping logs.
# Also if this is ever implemented flush_buffer() would have to use lock and ensure all data is sent to the thread.
if _io_thread_log_lock.lock():
_io_thread_formatted_messages.append_array(p_formatted_messages)
_io_thread_log_lock.unlock()
_io_thread_work_semaphore.post()
Expand Down

0 comments on commit 582a0a5

Please sign in to comment.