From ea0bf5e4c80a856ccdf6d37f1f2848418d916479 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 14 Dec 2020 14:52:36 +0100 Subject: [PATCH] ensure 64 bit alignment for 64 bit struct fields access atomically --- common/connection.go | 5 +++-- common/transfer.go | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/connection.go b/common/connection.go index 9832b567..71dce272 100644 --- a/common/connection.go +++ b/common/connection.go @@ -20,6 +20,9 @@ import ( // BaseConnection defines common fields for a connection using any supported protocol type BaseConnection struct { + // last activity for this connection. + // Since this is accessed atomically we put as first element of the struct achieve 64 bit alignment + lastActivity int64 // Unique identifier for the connection ID string // user associated with this connection if any @@ -29,8 +32,6 @@ type BaseConnection struct { protocol string Fs vfs.Fs sync.RWMutex - // last activity for this connection - lastActivity int64 transferID uint64 activeTransfers []ActiveTransfer } diff --git a/common/transfer.go b/common/transfer.go index fdb2232c..858bdae7 100644 --- a/common/transfer.go +++ b/common/transfer.go @@ -21,20 +21,20 @@ var ( // BaseTransfer contains protocols common transfer details for an upload or a download. type BaseTransfer struct { //nolint:maligned ID uint64 + BytesSent int64 + BytesReceived int64 Fs vfs.Fs File vfs.File Connection *BaseConnection cancelFn func() fsPath string + requestPath string start time.Time - transferType int + MaxWriteSize int64 MinWriteOffset int64 InitialSize int64 isNewFile bool - requestPath string - BytesSent int64 - BytesReceived int64 - MaxWriteSize int64 + transferType int AbortTransfer int32 sync.Mutex ErrTransfer error