multi: 64bit aligment of atomic vars on arm/x86-32

This commit is contained in:
maurycy
2018-06-01 00:41:41 +02:00
committed by Olaoluwa Osuntokun
parent d2bcb708f3
commit 3be08e69cf
21 changed files with 67 additions and 60 deletions

View File

@@ -51,8 +51,8 @@ var (
// and the current block height. DecayedLog wraps boltdb for simplicity and
// batches writes to the database to decrease write contention.
type DecayedLog struct {
started int32
stopped int32
started int32 // To be used atomically.
stopped int32 // To be used atomically.
dbPath string

View File

@@ -60,8 +60,8 @@ type MailBox interface {
// memoryMailBox is an implementation of the MailBox struct backed by purely
// in-memory queues.
type memoryMailBox struct {
started uint32
stopped uint32
started uint32 // To be used atomically.
stopped uint32 // To be used atomically.
wireMessages *list.List
wireHead *list.Element

View File

@@ -100,8 +100,8 @@ func (m *mockForwardingLog) AddForwardingEvents(events []channeldb.ForwardingEve
}
type mockServer struct {
started int32
shutdown int32
started int32 // To be used atomically.
shutdown int32 // To be used atomically.
wg sync.WaitGroup
quit chan struct{}

View File

@@ -17,6 +17,19 @@ import (
// to signal the number of slots available, and a condition variable to allow
// the packetQueue to know when new items have been added to the queue.
type packetQueue struct {
// queueLen is an internal counter that reflects the size of the queue
// at any given instance. This value is intended to be use atomically
// as this value is used by internal methods to obtain the length of
// the queue w/o grabbing the main lock. This allows callers to avoid a
// deadlock situation where the main goroutine is attempting a send
// with the lock held.
queueLen int32
// totalHtlcAmt is the sum of the value of all pending HTLC's currently
// residing within the overflow queue. This value should only read or
// modified *atomically*.
totalHtlcAmt int64
queue []*htlcPacket
wg sync.WaitGroup
@@ -33,20 +46,7 @@ type packetQueue struct {
// commitment transaction.
outgoingPkts chan *htlcPacket
// totalHtlcAmt is the sum of the value of all pending HTLC's currently
// residing within the overflow queue. This value should only read or
// modified *atomically*.
totalHtlcAmt int64
quit chan struct{}
// queueLen is an internal counter that reflects the size of the queue
// at any given instance. This value is intended to be use atomically
// as this value is used by internal methods to obtain the length of
// the queue w/o grabbing the main lock. This allows callers to avoid a
// deadlock situation where the main goroutine is attempting a send
// with the lock held.
queueLen int32
}
// newPacketQueue returns a new instance of the packetQueue. The maxFreeSlots

View File

@@ -153,8 +153,8 @@ type Config struct {
// HTLCs, forwarding HTLCs initiated from within the daemon, and finally
// notifies users local-systems concerning their outstanding payment requests.
type Switch struct {
started int32
shutdown int32
started int32 // To be used atomically.
shutdown int32 // To be used atomically.
wg sync.WaitGroup
quit chan struct{}