Skip to content

Commit

Permalink
spsc-queue: Reload cached_tail/head when opening queue
Browse files Browse the repository at this point in the history
Reload cached_tail/head when opening queues. This fixes
reconnecting to active queues.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
  • Loading branch information
edgarigl authored and sgherbst committed Jul 2, 2024
1 parent 1e816d8 commit 70247e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions switchboard/cpp/spsc_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ static inline spsc_queue* spsc_open_mem(const char* name, size_t capacity, void*
q->shm = (spsc_queue_shared*)p;
q->name = strdup(name);
q->capacity = capacity;

/* In case we're opening a pre-existing queue, pick up where we left off. */
__atomic_load(&q->shm->tail, &q->cached_tail, __ATOMIC_RELAXED);
__atomic_load(&q->shm->head, &q->cached_head, __ATOMIC_RELAXED);
return q;

err:
Expand Down

0 comments on commit 70247e6

Please sign in to comment.