From 10c52ac4095a7bc98fefbf9b02f3790cd698ccd4 Mon Sep 17 00:00:00 2001 From: matst80 Date: Tue, 18 Mar 2025 19:40:35 +0100 Subject: [PATCH] more logs --- synced-pool.go | 11 ++++++++--- tcp-connection.go | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/synced-pool.go b/synced-pool.go index 7557899..79ad578 100644 --- a/synced-pool.go +++ b/synced-pool.go @@ -408,10 +408,10 @@ func (p *SyncedPool) AddRemote(host string) { host_pool, err := netpool.New(func() (net.Conn, error) { return net.Dial("tcp", fmt.Sprintf("%s:1338", host)) - }, netpool.WithMaxPool(128), netpool.WithMinPool(16)) + }, netpool.WithMaxPool(128), netpool.WithMinPool(0)) if err != nil { - log.Printf("Error creating pool: %v\n", err) + log.Printf("Error creating host pool: %v\n", err) return } @@ -432,7 +432,12 @@ func (p *SyncedPool) AddRemote(host string) { cart_pool, err := netpool.New(func() (net.Conn, error) { return net.Dial("tcp", fmt.Sprintf("%s:1337", host)) - }, netpool.WithMaxPool(1024), netpool.WithMinPool(5)) + }, netpool.WithMaxPool(128), netpool.WithMinPool(0)) + + if err != nil { + log.Printf("Error creating grain pool: %v\n", err) + return + } remote := RemoteHost{ HostPool: cart_pool, diff --git a/tcp-connection.go b/tcp-connection.go index 0078256..f8e0b31 100644 --- a/tcp-connection.go +++ b/tcp-connection.go @@ -104,12 +104,11 @@ func (c *Connection) CallAsync(msg FrameType, payload []byte, ch chan<- FrameWit func (c *Connection) Call(msg FrameType, data []byte) (*FrameWithPayload, error) { ch := make(chan FrameWithPayload, 1) conn, err := c.CallAsync(msg, data, ch) - + defer c.pool.Put(conn, err) if err != nil { return nil, err } - defer c.pool.Put(conn, err) // conn.Close() defer close(ch) ret := <-ch @@ -181,6 +180,7 @@ const ( func (l *GenericListener) HandleConnection(conn net.Conn) { var err error var frame Frame + log.Printf("Server Connection accepted: %s\n", conn.RemoteAddr().String()) b := bufio.NewReader(conn) for err != io.EOF { @@ -197,6 +197,8 @@ func (l *GenericListener) HandleConnection(conn net.Conn) { } } } + conn.Close() + log.Printf("Server Connection closed") } func (l *GenericListener) AddHandler(msg FrameType, handler func(*FrameWithPayload, chan<- FrameWithPayload) error) {