|
|
@@ -11,11 +11,7 @@ type connectionList struct {
|
|
11
|
11
|
connections []*connection
|
|
12
|
12
|
}
|
|
13
|
13
|
|
|
14
|
|
-func (c *connectionList) Get(conn *ProxyConn) (*connection, error) {
|
|
15
|
|
- if len(c.connections) > 0 {
|
|
16
|
|
- c.gc()
|
|
17
|
|
- }
|
|
18
|
|
-
|
|
|
14
|
+func (c *connectionList) get(conn *ProxyConn) (*connection, error) {
|
|
19
|
15
|
if len(c.connections) > 0 && c.connections[0].Len() < config.C.MultiplexPerConnection {
|
|
20
|
16
|
if err := c.connections[0].Attach(conn); err == nil {
|
|
21
|
17
|
return c.connections[0], nil
|
|
|
@@ -41,6 +37,9 @@ func (c *connectionList) Get(conn *ProxyConn) (*connection, error) {
|
|
41
|
37
|
|
|
42
|
38
|
func (c *connectionList) gc() {
|
|
43
|
39
|
prevLen := len(c.connections)
|
|
|
40
|
+ if prevLen == 0 {
|
|
|
41
|
+ return
|
|
|
42
|
+ }
|
|
44
|
43
|
|
|
45
|
44
|
for i := len(c.connections) - 1; i >= 0; i-- {
|
|
46
|
45
|
lastIndex := len(c.connections) - 1
|