Skip to content
Snippets Groups Projects
Commit 7b3b9672 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

added the transmit mux to stop disconnects while operations are

ongoing with the host
parent eb3dca65
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,7 @@ type Host struct { ...@@ -82,6 +82,7 @@ type Host struct {
// Send lock // Send lock
sendMux sync.RWMutex sendMux sync.RWMutex
transmitMux sync.RWMutex
coolOffBucket *rateLimiting.Bucket coolOffBucket *rateLimiting.Bucket
inCoolOff bool inCoolOff bool
...@@ -221,8 +222,8 @@ func (h *Host) SetMetricsTesting(m *Metric, face interface{}) { ...@@ -221,8 +222,8 @@ func (h *Host) SetMetricsTesting(m *Metric, face interface{}) {
// Disconnect closes a the Host connection under the write lock // Disconnect closes a the Host connection under the write lock
func (h *Host) Disconnect() { func (h *Host) Disconnect() {
h.sendMux.Lock() h.transmitMux.Lock()
defer h.sendMux.Unlock() defer h.transmitMux.Unlock()
h.disconnect() h.disconnect()
} }
......
...@@ -27,6 +27,9 @@ func (c *ProtoComms) transmit(host *Host, f func(conn *grpc.ClientConn) (interfa ...@@ -27,6 +27,9 @@ func (c *ProtoComms) transmit(host *Host, f func(conn *grpc.ClientConn) (interfa
return nil, errors.New("Host address is blank, host might be receive only.") return nil, errors.New("Host address is blank, host might be receive only.")
} }
host.transmitMux.RLock()
defer host.transmitMux.RUnlock()
for numRetries := 0; numRetries < MaxRetries; numRetries++ { for numRetries := 0; numRetries < MaxRetries; numRetries++ {
err = nil err = nil
//reconnect if necessary //reconnect if necessary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment