From 4f3a97bcc376f5764e4a7aae6a495976865b311e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 29 May 2018 18:59:04 +0200 Subject: [PATCH] fix segfault on arm due to bad atomic access fixes #78 --- pubsub.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pubsub.go b/pubsub.go index a4f68a7..5d92af9 100644 --- a/pubsub.go +++ b/pubsub.go @@ -26,6 +26,13 @@ const ( var log = logging.Logger("pubsub") type PubSub struct { + // atomic counter for seqnos + // NOTE: Must be declared at the top of the struct as we perform atomic + // operations on this field. + // + // See: https://golang.org/pkg/sync/atomic/#pkg-note-BUG + counter uint64 + host host.Host rt PubSubRouter @@ -79,9 +86,6 @@ type PubSub struct { seenMessages *timecache.TimeCache ctx context.Context - - // atomic counter for seqnos - counter uint64 } // PubSubRouter is the message router component of PubSub