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 {
// Send lock
sendMux sync.RWMutex
transmitMux sync.RWMutex
coolOffBucket *rateLimiting.Bucket
inCoolOff bool
......@@ -221,8 +222,8 @@ func (h *Host) SetMetricsTesting(m *Metric, face interface{}) {
// Disconnect closes a the Host connection under the write lock
func (h *Host) Disconnect() {
h.sendMux.Lock()
defer h.sendMux.Unlock()
h.transmitMux.Lock()
defer h.transmitMux.Unlock()
h.disconnect()
}
......
......@@ -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.")
}
host.transmitMux.RLock()
defer host.transmitMux.RUnlock()
for numRetries := 0; numRetries < MaxRetries; numRetries++ {
err = nil
//reconnect if necessary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment