test/net-pool #2

Merged
mats merged 11 commits from test/net-pool into main 2024-11-23 15:30:38 +01:00
2 changed files with 9 additions and 7 deletions
Showing only changes of commit af5b060d09 - Show all commits

View File

@@ -391,7 +391,7 @@ func (p *SyncedPool) AddRemote(host string) {
host_pool, err := netpool.New(func() (net.Conn, error) { host_pool, err := netpool.New(func() (net.Conn, error) {
return net.Dial("tcp", fmt.Sprintf("%s:1338", host)) return net.Dial("tcp", fmt.Sprintf("%s:1338", host))
}, netpool.WithMaxPool(256), netpool.WithMinPool(5)) }, netpool.WithMaxPool(1024), netpool.WithMinPool(5))
if err != nil { if err != nil {
log.Printf("Error creating pool: %v\n", err) log.Printf("Error creating pool: %v\n", err)

View File

@@ -112,12 +112,14 @@ func (c *Connection) Call(msg FrameType, data []byte) (*FrameWithPayload, error)
defer c.pool.Put(conn, err) // conn.Close() defer c.pool.Put(conn, err) // conn.Close()
defer close(ch) defer close(ch)
select { ret := <-ch
case ret := <-ch: return &ret, nil
return &ret, nil // select {
case <-time.After(MaxCallDuration): // case ret := <-ch:
return nil, fmt.Errorf("timeout waiting for frame") // return &ret, nil
} // case <-time.After(MaxCallDuration):
// return nil, fmt.Errorf("timeout waiting for frame")
// }
} }
func WaitForFrame(conn net.Conn, resultChan chan<- FrameWithPayload) error { func WaitForFrame(conn net.Conn, resultChan chan<- FrameWithPayload) error {