File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import (
1717
1818const (
1919 _PING_INTERVAL = 20 * time .Second
20- _PING_TIMEOUT = 30 * time .Second // Should be > server's executorPingWait (25s)
20+ _PING_TIMEOUT = 30 * time .Second // Should be slightly greater than server's executorPingWait (25s)
2121 _INITIAL_RECONNECT_WAIT = 1 * time .Second
2222 _MAX_RECONNECT_WAIT = 30 * time .Second
2323 _HANDSHAKE_TIMEOUT = 10 * time .Second
@@ -118,6 +118,8 @@ func (c *Conductor) Shutdown(timeout time.Duration) {
118118 c .pingCancel ()
119119 }
120120
121+ c .closeConn ()
122+
121123 done := make (chan struct {})
122124 go func () {
123125 c .wg .Wait ()
@@ -141,6 +143,10 @@ func (c *Conductor) closeConn() {
141143 c .pingCancel = nil
142144 }
143145
146+ // Acquire write mutex to ensure no concurrent writes during close
147+ c .writeMu .Lock ()
148+ defer c .writeMu .Unlock ()
149+
144150 if c .conn != nil {
145151 if err := c .conn .SetWriteDeadline (time .Now ().Add (5 * time .Second )); err != nil {
146152 c .logger .Warn ("Failed to set write deadline" , "error" , err )
You can’t perform that action at this time.
0 commit comments