Move int64s to top of struct to resolve alignment issue on ARM (#2521)

* move int64s to top of struct to resolve alignment issue on ARM
This commit is contained in:
ethanadams 2019-07-10 13:47:22 -04:00 committed by GitHub
parent 0d294103e9
commit f06aec06fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -22,9 +22,10 @@ type bandwidthdb struct {
}
type bandwidthUsed struct {
// Moved to top of struct to resolve alignment issue with atomic operations on ARM
used int64
mu sync.RWMutex
usedSince time.Time
used int64
}
// Bandwidth returns table for storing bandwidth usage.

View File

@ -44,8 +44,8 @@ func newInfo(path string) (*InfoDB, error) {
dbutil.Configure(db, mon)
infoDb := &InfoDB{db: db}
infoDb.pieceinfo = pieceinfo{infoDb, spaceUsed{sync.Once{}, 0}}
infoDb.bandwidthdb = bandwidthdb{infoDb, bandwidthUsed{sync.RWMutex{}, time.Time{}, 0}}
infoDb.pieceinfo = pieceinfo{InfoDB: infoDb, space: spaceUsed{used: 0, once: sync.Once{}}}
infoDb.bandwidthdb = bandwidthdb{InfoDB: infoDb, bandwidth: bandwidthUsed{used: 0, mu: sync.RWMutex{}, usedSince: time.Time{}}}
return infoDb, nil
}
@ -70,8 +70,8 @@ func NewInfoInMemory() (*InfoDB, error) {
}))
infoDb := &InfoDB{db: db}
infoDb.pieceinfo = pieceinfo{infoDb, spaceUsed{sync.Once{}, 0}}
infoDb.bandwidthdb = bandwidthdb{infoDb, bandwidthUsed{sync.RWMutex{}, time.Time{}, 0}}
infoDb.pieceinfo = pieceinfo{InfoDB: infoDb, space: spaceUsed{used: 0, once: sync.Once{}}}
infoDb.bandwidthdb = bandwidthdb{InfoDB: infoDb, bandwidth: bandwidthUsed{used: 0, mu: sync.RWMutex{}, usedSince: time.Time{}}}
return infoDb, nil
}

View File

@ -24,8 +24,9 @@ type pieceinfo struct {
}
type spaceUsed struct {
once sync.Once
// Moved to top of struct to resolve alignment issue with atomic operations on ARM
used int64
once sync.Once
}
// PieceInfo returns database for storing piece information