multi: 64bit aligment of atomic vars on arm/x86-32
This commit is contained in:
parent
d2bcb708f3
commit
3be08e69cf
@ -22,7 +22,7 @@ var (
|
|||||||
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
|
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
|
||||||
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
|
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
|
||||||
|
|
||||||
chanIDCounter uint64
|
chanIDCounter uint64 // To be used atomically.
|
||||||
)
|
)
|
||||||
|
|
||||||
// databaseChannelGraph wraps a channeldb.ChannelGraph instance with the
|
// databaseChannelGraph wraps a channeldb.ChannelGraph instance with the
|
||||||
|
@ -111,8 +111,8 @@ type BreachConfig struct {
|
|||||||
// counterparties.
|
// counterparties.
|
||||||
// TODO(roasbeef): closures in config for subsystem pointers to decouple?
|
// TODO(roasbeef): closures in config for subsystem pointers to decouple?
|
||||||
type breachArbiter struct {
|
type breachArbiter struct {
|
||||||
started uint32
|
started uint32 // To be used atomically.
|
||||||
stopped uint32
|
stopped uint32 // To be used atomically.
|
||||||
|
|
||||||
cfg *BreachConfig
|
cfg *BreachConfig
|
||||||
|
|
||||||
|
@ -134,8 +134,8 @@ type ChainArbitratorConfig struct {
|
|||||||
// forcibly exit a contract, update the set of live signals for each contract,
|
// forcibly exit a contract, update the set of live signals for each contract,
|
||||||
// and to receive reports on the state of contract resolution.
|
// and to receive reports on the state of contract resolution.
|
||||||
type ChainArbitrator struct {
|
type ChainArbitrator struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ type chainWatcherConfig struct {
|
|||||||
// that the channel has been closed, and also give them the materials necessary
|
// that the channel has been closed, and also give them the materials necessary
|
||||||
// to sweep the funds of the channel on chain eventually.
|
// to sweep the funds of the channel on chain eventually.
|
||||||
type chainWatcher struct {
|
type chainWatcher struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
@ -148,8 +148,8 @@ func newHtlcSet(htlcs []channeldb.HTLC) htlcSet {
|
|||||||
// broadcasting to ensure that we avoid any possibility of race conditions, and
|
// broadcasting to ensure that we avoid any possibility of race conditions, and
|
||||||
// sweep the output(s) without contest.
|
// sweep the output(s) without contest.
|
||||||
type ChannelArbitrator struct {
|
type ChannelArbitrator struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
// log is a persistent log that the attendant will use to checkpoint
|
// log is a persistent log that the attendant will use to checkpoint
|
||||||
// its next action, and the state of any unresolved contracts.
|
// its next action, and the state of any unresolved contracts.
|
||||||
|
@ -139,9 +139,14 @@ type Config struct {
|
|||||||
// will be rejected by this struct.
|
// will be rejected by this struct.
|
||||||
type AuthenticatedGossiper struct {
|
type AuthenticatedGossiper struct {
|
||||||
// Parameters which are needed to properly handle the start and stop of
|
// Parameters which are needed to properly handle the start and stop of
|
||||||
// the service.
|
// the service. To be used atomically.
|
||||||
started uint32
|
started uint32
|
||||||
stopped uint32
|
stopped uint32
|
||||||
|
|
||||||
|
// bestHeight is the height of the block at the tip of the main chain
|
||||||
|
// as we know it. To be used atomically.
|
||||||
|
bestHeight uint32
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
@ -186,10 +191,6 @@ type AuthenticatedGossiper struct {
|
|||||||
// forwarding policy of a set of channels is sent over.
|
// forwarding policy of a set of channels is sent over.
|
||||||
chanPolicyUpdates chan *chanPolicyUpdateRequest
|
chanPolicyUpdates chan *chanPolicyUpdateRequest
|
||||||
|
|
||||||
// bestHeight is the height of the block at the tip of the main chain
|
|
||||||
// as we know it.
|
|
||||||
bestHeight uint32
|
|
||||||
|
|
||||||
// selfKey is the identity public key of the backing Lightning node.
|
// selfKey is the identity public key of the backing Lightning node.
|
||||||
selfKey *btcec.PublicKey
|
selfKey *btcec.PublicKey
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ var (
|
|||||||
// and the current block height. DecayedLog wraps boltdb for simplicity and
|
// and the current block height. DecayedLog wraps boltdb for simplicity and
|
||||||
// batches writes to the database to decrease write contention.
|
// batches writes to the database to decrease write contention.
|
||||||
type DecayedLog struct {
|
type DecayedLog struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
dbPath string
|
dbPath string
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ type MailBox interface {
|
|||||||
// memoryMailBox is an implementation of the MailBox struct backed by purely
|
// memoryMailBox is an implementation of the MailBox struct backed by purely
|
||||||
// in-memory queues.
|
// in-memory queues.
|
||||||
type memoryMailBox struct {
|
type memoryMailBox struct {
|
||||||
started uint32
|
started uint32 // To be used atomically.
|
||||||
stopped uint32
|
stopped uint32 // To be used atomically.
|
||||||
|
|
||||||
wireMessages *list.List
|
wireMessages *list.List
|
||||||
wireHead *list.Element
|
wireHead *list.Element
|
||||||
|
@ -100,8 +100,8 @@ func (m *mockForwardingLog) AddForwardingEvents(events []channeldb.ForwardingEve
|
|||||||
}
|
}
|
||||||
|
|
||||||
type mockServer struct {
|
type mockServer struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
shutdown int32
|
shutdown int32 // To be used atomically.
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
|
||||||
|
@ -17,6 +17,19 @@ import (
|
|||||||
// to signal the number of slots available, and a condition variable to allow
|
// 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.
|
// the packetQueue to know when new items have been added to the queue.
|
||||||
type packetQueue struct {
|
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
|
queue []*htlcPacket
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
@ -33,20 +46,7 @@ type packetQueue struct {
|
|||||||
// commitment transaction.
|
// commitment transaction.
|
||||||
outgoingPkts chan *htlcPacket
|
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{}
|
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
|
// newPacketQueue returns a new instance of the packetQueue. The maxFreeSlots
|
||||||
|
@ -153,8 +153,8 @@ type Config struct {
|
|||||||
// HTLCs, forwarding HTLCs initiated from within the daemon, and finally
|
// HTLCs, forwarding HTLCs initiated from within the daemon, and finally
|
||||||
// notifies users local-systems concerning their outstanding payment requests.
|
// notifies users local-systems concerning their outstanding payment requests.
|
||||||
type Switch struct {
|
type Switch struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
shutdown int32
|
shutdown int32 // To be used atomically.
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
|
||||||
|
@ -1241,6 +1241,8 @@ func compactLogs(ourLog, theirLog *updateLog,
|
|||||||
//
|
//
|
||||||
// See the individual comments within the above methods for further details.
|
// See the individual comments within the above methods for further details.
|
||||||
type LightningChannel struct {
|
type LightningChannel struct {
|
||||||
|
shutdown int32 // To be used atomically.
|
||||||
|
|
||||||
// Signer is the main signer instances that will be responsible for
|
// Signer is the main signer instances that will be responsible for
|
||||||
// signing any HTLC and commitment transaction generated by the state
|
// signing any HTLC and commitment transaction generated by the state
|
||||||
// machine.
|
// machine.
|
||||||
@ -1330,7 +1332,6 @@ type LightningChannel struct {
|
|||||||
cowg sync.WaitGroup
|
cowg sync.WaitGroup
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
shutdown int32
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ type signJobResp struct {
|
|||||||
// TODO(roasbeef): rename?
|
// TODO(roasbeef): rename?
|
||||||
// * ecdsaPool?
|
// * ecdsaPool?
|
||||||
type sigPool struct {
|
type sigPool struct {
|
||||||
started uint32
|
started uint32 // To be used atomically.
|
||||||
stopped uint32
|
stopped uint32 // To be used atomically.
|
||||||
|
|
||||||
signer Signer
|
signer Signer
|
||||||
|
|
||||||
|
@ -221,6 +221,11 @@ type addSingleFunderSigsMsg struct {
|
|||||||
// Bitcoin Core + ZeroMQ, etc. Eventually, the wallet won't require a full-node
|
// Bitcoin Core + ZeroMQ, etc. Eventually, the wallet won't require a full-node
|
||||||
// at all, as SPV support is integrated into btcwallet.
|
// at all, as SPV support is integrated into btcwallet.
|
||||||
type LightningWallet struct {
|
type LightningWallet struct {
|
||||||
|
started int32 // To be used atomically.
|
||||||
|
shutdown int32 // To be used atomically.
|
||||||
|
|
||||||
|
nextFundingID uint64 // To be used atomically.
|
||||||
|
|
||||||
// Cfg is the configuration struct that will be used by the wallet to
|
// Cfg is the configuration struct that will be used by the wallet to
|
||||||
// access the necessary interfaces and default it needs to carry on its
|
// access the necessary interfaces and default it needs to carry on its
|
||||||
// duties.
|
// duties.
|
||||||
@ -258,7 +263,6 @@ type LightningWallet struct {
|
|||||||
// monotonically integer. All requests concerning the channel MUST
|
// monotonically integer. All requests concerning the channel MUST
|
||||||
// carry a valid, active funding ID.
|
// carry a valid, active funding ID.
|
||||||
fundingLimbo map[uint64]*ChannelReservation
|
fundingLimbo map[uint64]*ChannelReservation
|
||||||
nextFundingID uint64
|
|
||||||
limboMtx sync.RWMutex
|
limboMtx sync.RWMutex
|
||||||
|
|
||||||
// lockedOutPoints is a set of the currently locked outpoint. This
|
// lockedOutPoints is a set of the currently locked outpoint. This
|
||||||
@ -266,8 +270,6 @@ type LightningWallet struct {
|
|||||||
// the currently locked outpoints.
|
// the currently locked outpoints.
|
||||||
lockedOutPoints map[wire.OutPoint]struct{}
|
lockedOutPoints map[wire.OutPoint]struct{}
|
||||||
|
|
||||||
started int32
|
|
||||||
shutdown int32
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
14
peer.go
14
peer.go
@ -84,23 +84,25 @@ type chanSnapshotReq struct {
|
|||||||
// channels.
|
// channels.
|
||||||
// TODO(roasbeef): proper reconnection logic
|
// TODO(roasbeef): proper reconnection logic
|
||||||
type peer struct {
|
type peer struct {
|
||||||
|
// MUST be used atomically.
|
||||||
|
started int32
|
||||||
|
disconnect int32
|
||||||
|
|
||||||
// The following fields are only meant to be used *atomically*
|
// The following fields are only meant to be used *atomically*
|
||||||
bytesReceived uint64
|
bytesReceived uint64
|
||||||
bytesSent uint64
|
bytesSent uint64
|
||||||
|
|
||||||
|
|
||||||
// pingTime is a rough estimate of the RTT (round-trip-time) between us
|
// pingTime is a rough estimate of the RTT (round-trip-time) between us
|
||||||
// and the connected peer. This time is expressed in micro seconds.
|
// and the connected peer. This time is expressed in micro seconds.
|
||||||
|
// To be used atomically.
|
||||||
// TODO(roasbeef): also use a WMA or EMA?
|
// TODO(roasbeef): also use a WMA or EMA?
|
||||||
pingTime int64
|
pingTime int64
|
||||||
|
|
||||||
// pingLastSend is the Unix time expressed in nanoseconds when we sent
|
// pingLastSend is the Unix time expressed in nanoseconds when we sent
|
||||||
// our last ping message.
|
// our last ping message. To be used atomically.
|
||||||
pingLastSend int64
|
pingLastSend int64
|
||||||
|
|
||||||
// MUST be used atomically.
|
|
||||||
started int32
|
|
||||||
disconnect int32
|
|
||||||
|
|
||||||
connReq *connmgr.ConnReq
|
connReq *connmgr.ConnReq
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
|
|
||||||
@ -624,7 +626,7 @@ func (p *peer) readNextMessage() (lnwire.Message, error) {
|
|||||||
// TODO(conner): use stream handler interface to abstract out stream
|
// TODO(conner): use stream handler interface to abstract out stream
|
||||||
// state/logging
|
// state/logging
|
||||||
type msgStream struct {
|
type msgStream struct {
|
||||||
streamShutdown int32
|
streamShutdown int32 // To be used atomically.
|
||||||
|
|
||||||
peer *peer
|
peer *peer
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
// BitcoindFilteredChainView is an implementation of the FilteredChainView
|
// BitcoindFilteredChainView is an implementation of the FilteredChainView
|
||||||
// interface which is backed by bitcoind.
|
// interface which is backed by bitcoind.
|
||||||
type BitcoindFilteredChainView struct {
|
type BitcoindFilteredChainView struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
// bestHeight is the height of the latest block added to the
|
// bestHeight is the height of the latest block added to the
|
||||||
// blockQueue from the onFilteredConnectedMethod. It is used to
|
// blockQueue from the onFilteredConnectedMethod. It is used to
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
// BtcdFilteredChainView is an implementation of the FilteredChainView
|
// BtcdFilteredChainView is an implementation of the FilteredChainView
|
||||||
// interface which is backed by an active websockets connection to btcd.
|
// interface which is backed by an active websockets connection to btcd.
|
||||||
type BtcdFilteredChainView struct {
|
type BtcdFilteredChainView struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
// bestHeight is the height of the latest block added to the
|
// bestHeight is the height of the latest block added to the
|
||||||
// blockQueue from the onFilteredConnectedMethod. It is used to
|
// blockQueue from the onFilteredConnectedMethod. It is used to
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
// blocks, the light client is able to query filters locally, to test if an
|
// blocks, the light client is able to query filters locally, to test if an
|
||||||
// item in a block modifies any of our watched set of UTXOs.
|
// item in a block modifies any of our watched set of UTXOs.
|
||||||
type CfFilteredChainView struct {
|
type CfFilteredChainView struct {
|
||||||
started int32
|
started int32 // To be used atomically.
|
||||||
stopped int32
|
stopped int32 // To be used atomically.
|
||||||
|
|
||||||
// p2pNode is a pointer to the running GCS-filter supported Bitcoin
|
// p2pNode is a pointer to the running GCS-filter supported Bitcoin
|
||||||
// light clientl
|
// light clientl
|
||||||
|
@ -200,12 +200,12 @@ func newRouteTuple(amt lnwire.MilliSatoshi, dest []byte) routeTuple {
|
|||||||
// automatically as new blocks are discovered which spend certain known funding
|
// automatically as new blocks are discovered which spend certain known funding
|
||||||
// outpoints, thereby closing their respective channels.
|
// outpoints, thereby closing their respective channels.
|
||||||
type ChannelRouter struct {
|
type ChannelRouter struct {
|
||||||
ntfnClientCounter uint64
|
ntfnClientCounter uint64 // To be used atomically.
|
||||||
|
|
||||||
started uint32
|
started uint32 // To be used atomically.
|
||||||
stopped uint32
|
stopped uint32 // To be used atomically.
|
||||||
|
|
||||||
bestHeight uint32
|
bestHeight uint32 // To be used atomically.
|
||||||
|
|
||||||
// cfg is a copy of the configuration struct that the ChannelRouter was
|
// cfg is a copy of the configuration struct that the ChannelRouter was
|
||||||
// initialized with.
|
// initialized with.
|
||||||
|
@ -762,7 +762,8 @@ func (s *server) peerBootstrapper(numTargetPeers uint32,
|
|||||||
|
|
||||||
// We'll use the number of attempts and errors to determine if we need
|
// We'll use the number of attempts and errors to determine if we need
|
||||||
// to increase the time between discovery epochs.
|
// to increase the time between discovery epochs.
|
||||||
var epochErrors, epochAttempts uint32
|
var epochErrors uint32 // To be used atomically.
|
||||||
|
var epochAttempts uint32
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -220,8 +220,8 @@ type NurseryConfig struct {
|
|||||||
// the source wallet, returning the outputs so they can be used within future
|
// the source wallet, returning the outputs so they can be used within future
|
||||||
// channels, or regular Bitcoin transactions.
|
// channels, or regular Bitcoin transactions.
|
||||||
type utxoNursery struct {
|
type utxoNursery struct {
|
||||||
started uint32
|
started uint32 // To be used atomically.
|
||||||
stopped uint32
|
stopped uint32 // To be used atomically.
|
||||||
|
|
||||||
cfg *NurseryConfig
|
cfg *NurseryConfig
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user