mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Fix races in IAM cache lazy loading (#19346)
Fix races in IAM cache
Fixes #19344
On the top level we only grab a read lock, but we write to the cache if we manage to fetch it.
a03dac41eb/cmd/iam-store.go (L446) is also flipped to what it should be AFAICT.
Change the internal cache structure to a concurrency safe implementation.
Bonus: Also switch grid implementation.
This commit is contained in:
@@ -42,6 +42,7 @@ import (
|
||||
xioutil "github.com/minio/minio/internal/ioutil"
|
||||
"github.com/minio/minio/internal/logger"
|
||||
"github.com/minio/minio/internal/pubsub"
|
||||
"github.com/puzpuzpuz/xsync/v3"
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
"github.com/zeebo/xxh3"
|
||||
)
|
||||
@@ -75,10 +76,10 @@ type Connection struct {
|
||||
ctx context.Context
|
||||
|
||||
// Active mux connections.
|
||||
outgoing *lockedClientMap
|
||||
outgoing *xsync.MapOf[uint64, *muxClient]
|
||||
|
||||
// Incoming streams
|
||||
inStream *lockedServerMap
|
||||
inStream *xsync.MapOf[uint64, *muxServer]
|
||||
|
||||
// outQueue is the output queue
|
||||
outQueue chan []byte
|
||||
@@ -205,8 +206,8 @@ func newConnection(o connectionParams) *Connection {
|
||||
Local: o.local,
|
||||
id: o.id,
|
||||
ctx: o.ctx,
|
||||
outgoing: &lockedClientMap{m: make(map[uint64]*muxClient, 1000)},
|
||||
inStream: &lockedServerMap{m: make(map[uint64]*muxServer, 1000)},
|
||||
outgoing: xsync.NewMapOfPresized[uint64, *muxClient](1000),
|
||||
inStream: xsync.NewMapOfPresized[uint64, *muxServer](1000),
|
||||
outQueue: make(chan []byte, defaultOutQueue),
|
||||
dialer: o.dial,
|
||||
side: ws.StateServerSide,
|
||||
|
||||
Reference in New Issue
Block a user