Skip to content

Commit 09c54d3

Browse files
committed
REORG/MINOR: runtime: use a Mutex instead of a RWMutex
Also document why we are using a mutex in the first place.
1 parent d63576b commit 09c54d3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

runtime/runtime_single_client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type socketType string
3939
type SingleRuntime struct {
4040
socketPath string
4141
masterWorkerMode bool
42-
mtx sync.RWMutex
42+
mtx sync.Mutex
4343
}
4444

4545
func (s *SingleRuntime) IsValid() bool {
@@ -79,8 +79,14 @@ func (s *SingleRuntime) Init(socketPath string, masterWorkerMode bool, opt ...op
7979
}
8080

8181
func (s *SingleRuntime) readFromSocket(command string, socket socketType) (string, error) {
82+
// While HAProxy's stat socket supports concurrent connections,
83+
// we use a mutex here for the following reasons:
84+
// - some commands must not be run in parallel, e.g., "set ssl cert" which creates a transaction
85+
// - the Master socket is limited to 10 connections
86+
// - at least we are sure of never reaching somaxconn
8287
s.mtx.Lock()
8388
defer s.mtx.Unlock()
89+
8490
var api net.Conn
8591
var err error
8692

0 commit comments

Comments
 (0)