Browse Source

control: disable write coalescing the control conn (#1244)

Chris Bannister 7 years ago
parent
commit
33c0e89ca9
2 changed files with 8 additions and 2 deletions
  1. 4 2
      conn.go
  2. 4 0
      control.go

+ 4 - 2
conn.go

@@ -99,7 +99,9 @@ type ConnConfig struct {
 	Compressor     Compressor
 	Compressor     Compressor
 	Authenticator  Authenticator
 	Authenticator  Authenticator
 	Keepalive      time.Duration
 	Keepalive      time.Duration
-	tlsConfig      *tls.Config
+
+	tlsConfig       *tls.Config
+	disableCoalesce bool
 }
 }
 
 
 type ConnErrorHandler interface {
 type ConnErrorHandler interface {
@@ -240,7 +242,7 @@ func (s *Session) dial(host *HostInfo, cfg *ConnConfig, errorHandler ConnErrorHa
 	c.timeout = cfg.Timeout
 	c.timeout = cfg.Timeout
 
 
 	// dont coalesce startup frames
 	// dont coalesce startup frames
-	if s.cfg.WriteCoalesceWaitTime > 0 {
+	if s.cfg.WriteCoalesceWaitTime > 0 && !cfg.disableCoalesce {
 		c.w = newWriteCoalescer(c.w, s.cfg.WriteCoalesceWaitTime, c.quit)
 		c.w = newWriteCoalescer(c.w, s.cfg.WriteCoalesceWaitTime, c.quit)
 	}
 	}
 
 

+ 4 - 0
control.go

@@ -166,9 +166,13 @@ func (c *controlConn) shuffleDial(endpoints []*HostInfo) (*Conn, error) {
 	// node.
 	// node.
 	shuffled := shuffleHosts(endpoints)
 	shuffled := shuffleHosts(endpoints)
 
 
+	cfg := *c.session.connCfg
+	cfg.disableCoalesce = true
+
 	var err error
 	var err error
 	for _, host := range shuffled {
 	for _, host := range shuffled {
 		var conn *Conn
 		var conn *Conn
+		c.session.dial(host, &cfg, c)
 		conn, err = c.session.connect(host, c)
 		conn, err = c.session.connect(host, c)
 		if err == nil {
 		if err == nil {
 			return conn, nil
 			return conn, nil