Skip to content

Commit

Permalink
error.c: make our 'global' state be thread local
Browse files Browse the repository at this point in the history
Because the error log array can be changed in any call, it could be
modified by more than one thread at once.  This means that the results
won't make any sense - even absent actual execution errors as a result,
the best case is intermixed error logs from different threads.

This makes the error log pointer thread local, so that each thread will
effectively get its own error log.

Fixes github issue rhboot#154

Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela committed Oct 1, 2020
1 parent 820be6e commit 555066e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ typedef struct {
char *message;
} error_table_entry;

static error_table_entry *error_table;
static unsigned int current;
static _Thread_local error_table_entry *error_table;
static _Thread_local unsigned int current;

int PUBLIC NONNULL(2, 3, 4, 5, 6)
efi_error_get(unsigned int n,
Expand Down

0 comments on commit 555066e

Please sign in to comment.