فهرست منبع

Resolved issue of connections reconnecting in an infinite loop consuming
all available ports.

Updated the gocql_test to pause for 15 seconds to test that this issue
doesn't recur in future releases.

Phillip Couto 12 سال پیش
والد
کامیت
c0c4dafb44
2فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  1. 4 2
      cluster.go
  2. 3 0
      gocql_test/main.go

+ 4 - 2
cluster.go

@@ -59,7 +59,7 @@ func (cfg *ClusterConfig) CreateSession() *Session {
 		connPool: make(map[string]*RoundRobin),
 		conns:    make(map[*Conn]struct{}),
 		quitWait: make(chan bool),
-		keyspace: cfg.Keyspace,		
+		keyspace: cfg.Keyspace,
 	}
 	impl.wgStart.Add(1)
 	for i := 0; i < len(impl.cfg.Hosts); i++ {
@@ -179,7 +179,9 @@ func (c *clusterImpl) HandleError(conn *Conn, err error, closed bool) {
 		return
 	}
 	c.removeConn(conn)
-	go c.connect(conn.Address()) // reconnect
+	if !c.quit {
+		go c.connect(conn.Address()) // reconnect
+	}
 }
 
 func (c *clusterImpl) HandleKeyspace(conn *Conn, keyspace string) {

+ 3 - 0
gocql_test/main.go

@@ -51,7 +51,10 @@ func initSchema() error {
 		}`).Exec(); err != nil {
 		return err
 	}
+	log.Println("Testing that the connections do not reconnect in an infinite loop.")
 	session.Close()
+	time.Sleep(15 * time.Second)
+	log.Println("If there were error messages that an address cannot be assigned then the test failed.")
 	cluster.Keyspace = "gocql_test"
 	session = cluster.CreateSession()