From d38bea818a90a0ca2bfc17e96c00b9896e2c61ca Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Sat, 4 Jun 2022 04:02:07 -0400 Subject: [Bugfix #21] Bad alignment of elements in structs accessed atomically Fixes #21 --- lgc/lgc.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lgc') diff --git a/lgc/lgc.go b/lgc/lgc.go index 59b623d..13f2c06 100644 --- a/lgc/lgc.go +++ b/lgc/lgc.go @@ -40,12 +40,14 @@ type LoadGeneratingConnection interface { ClientId() uint64 } +// TODO: All 64-bit fields that are accessed atomically must +// appear at the top of this struct. type LoadGeneratingConnectionDownload struct { - Path string downloaded uint64 + lastIntervalEnd int64 + Path string downloadStartTime time.Time lastDownloaded uint64 - lastIntervalEnd int64 client *http.Client debug debug.DebugLevel valid bool @@ -312,12 +314,14 @@ func (lbd *LoadGeneratingConnectionDownload) doDownload(ctx context.Context) { } } +// TODO: All 64-bit fields that are accessed atomically must +// appear at the top of this struct. type LoadGeneratingConnectionUpload struct { - Path string uploaded uint64 + lastIntervalEnd int64 + Path string uploadStartTime time.Time lastUploaded uint64 - lastIntervalEnd int64 client *http.Client debug debug.DebugLevel valid bool -- cgit v1.2.3