gunli opened a new issue, #11660:
URL: https://github.com/apache/inlong/issues/11660

   ### Description
   
   Currently, `connPool.initConns()` forgets to close the exist conntections 
when it got any error, it the better to close the exist connections.
   ```go
   func (p *connPool) initConns(count int) error {
        // create some conns and then put them back to the pool
        var wg sync.WaitGroup
        conns := make(chan gnet.Conn, count)
        errs := make(chan error, count)
   
        for i := 0; i < count; i++ {
                wg.Add(1)
                go func() {
                        defer wg.Done()
                        conn, err := p.newConn()
                        if err != nil {
                                errs <- err
                                return
                        }
                        conns <- conn
                }()
        }
   
        wg.Wait()
        close(conns)
        close(errs)
   
        for err := range errs {
                if err != nil {
                           // forget to close the exist connections here
                        return err
                }
        }
   
        for conn := range conns {
                p.put(conn, nil, true)
        }
   
        return nil
   }
   ```
   
   ### InLong Component
   
   InLong SDK
   
   ### Are you willing to submit PR?
   
   - [x] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to