mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 15:35:41 +00:00
make 64bit atomics also align on 32bit (#2386)
do this by simply putting them at the front of each struct see https://pkg.go.dev/sync/atomic#pkg-note-BUG fixes #2383 Co-authored-by: akarl10 <mike@mwys.mine.bz>
This commit is contained in:
@@ -137,6 +137,10 @@ type ParticipantParams struct {
|
||||
}
|
||||
|
||||
type ParticipantImpl struct {
|
||||
// utils.TimedVersion is a atomic. To be correctly aligned also on 32bit archs
|
||||
// 64it atomics need to be at the front of a struct
|
||||
timedVersion utils.TimedVersion
|
||||
|
||||
params ParticipantParams
|
||||
|
||||
isClosed atomic.Bool
|
||||
@@ -200,7 +204,6 @@ type ParticipantImpl struct {
|
||||
|
||||
dirty atomic.Bool
|
||||
version atomic.Uint32
|
||||
timedVersion utils.TimedVersion
|
||||
|
||||
// callbacks & handlers
|
||||
onTrackPublished func(types.LocalParticipant, types.MediaTrack)
|
||||
|
||||
@@ -80,6 +80,15 @@ type disconnectSignalOnResumeNoMessages struct {
|
||||
}
|
||||
|
||||
type Room struct {
|
||||
// atomics always need to be 64bit/8byte aligned
|
||||
// on 32bit arch only the beginning of the struct
|
||||
// starts at such a boundary.
|
||||
// time the first participant joined the room
|
||||
joinedAt atomic.Int64
|
||||
// time that the last participant left the room
|
||||
leftAt atomic.Int64
|
||||
holds atomic.Int32
|
||||
|
||||
lock sync.RWMutex
|
||||
|
||||
protoRoom *livekit.Room
|
||||
@@ -109,11 +118,6 @@ type Room struct {
|
||||
batchedUpdates map[livekit.ParticipantIdentity]*participantUpdate
|
||||
batchedUpdatesMu sync.Mutex
|
||||
|
||||
// time the first participant joined the room
|
||||
joinedAt atomic.Int64
|
||||
holds atomic.Int32
|
||||
// time that the last participant left the room
|
||||
leftAt atomic.Int64
|
||||
closed chan struct{}
|
||||
|
||||
trailer []byte
|
||||
|
||||
@@ -37,6 +37,10 @@ type UpTrackManagerParams struct {
|
||||
|
||||
// UpTrackManager manages all uptracks from a participant
|
||||
type UpTrackManager struct {
|
||||
// utils.TimedVersion is a atomic. To be correctly aligned also on 32bit archs
|
||||
// 64it atomics need to be at the front of a struct
|
||||
subscriptionPermissionVersion utils.TimedVersion
|
||||
|
||||
params UpTrackManagerParams
|
||||
|
||||
closed bool
|
||||
@@ -44,7 +48,6 @@ type UpTrackManager struct {
|
||||
// publishedTracks that participant is publishing
|
||||
publishedTracks map[livekit.TrackID]types.MediaTrack
|
||||
subscriptionPermission *livekit.SubscriptionPermission
|
||||
subscriptionPermissionVersion utils.TimedVersion
|
||||
// subscriber permission for published tracks
|
||||
subscriberPermissions map[livekit.ParticipantIdentity]*livekit.TrackPermission // subscriberIdentity => *livekit.TrackPermission
|
||||
|
||||
|
||||
Reference in New Issue
Block a user