From 203f282bad26694e68d1326e6acf57f28db071d0 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Sat, 22 Jun 2013 19:12:58 +0600 Subject: [PATCH] Fixed buffer sharing --- replay/replay.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/replay/replay.go b/replay/replay.go index 466872c..6de227f 100644 --- a/replay/replay.go +++ b/replay/replay.go @@ -54,8 +54,6 @@ func ParseRequest(data []byte) (request *http.Request, err error) { // Replay server listen to UDP traffic from Listeners // Each request processed by RequestFactory func Run() { - buf := make([]byte, bufSize) - listener, err := net.Listen("tcp", Settings.Address()) log.Println("Starting replay server at:", Settings.Address()) @@ -78,16 +76,19 @@ func Run() { continue } - go handleConnection(conn, buf, requestFactory) + go handleConnection(conn, requestFactory) } } -func handleConnection(conn net.Conn, buf []byte, rf *RequestFactory) error { +func handleConnection(conn net.Conn, rf *RequestFactory) error { defer conn.Close() var read = true var response []byte + var buf []byte + + buf = make([]byte, bufSize) for read { log.Println("Start reading")