From 25a7fac4f0a2cd6287bab7a6da7be4250f81d956 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Tue, 6 Apr 2021 14:28:29 -0400 Subject: [PATCH] use wait group not stopper --- peer/http3/server.go | 8 ++++---- peer/http3/worker.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/peer/http3/server.go b/peer/http3/server.go index 2147421..89a64db 100644 --- a/peer/http3/server.go +++ b/peer/http3/server.go @@ -11,6 +11,7 @@ import ( "math/big" "net/http" "strconv" + "sync" "time" "github.com/lbryio/reflector.go/internal/metrics" @@ -70,11 +71,10 @@ func (s *Server) Start(address string) error { } r := mux.NewRouter() r.HandleFunc("/get/{hash}", func(w http.ResponseWriter, r *http.Request) { - waiter := stop.New() + waiter := &sync.WaitGroup{} + waiter.Add(1) enqueue(&blobRequest{request: r, reply: w, finished: waiter}) - select { - case <-waiter.Ch(): - } + waiter.Wait() }) r.HandleFunc("/has/{hash}", func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/peer/http3/worker.go b/peer/http3/worker.go index 62c4c4d..dac2893 100644 --- a/peer/http3/worker.go +++ b/peer/http3/worker.go @@ -2,6 +2,7 @@ package http3 import ( "net/http" + "sync" "github.com/lbryio/reflector.go/internal/metrics" @@ -11,7 +12,7 @@ import ( type blobRequest struct { request *http.Request reply http.ResponseWriter - finished *stop.Group + finished *sync.WaitGroup } var getReqCh = make(chan *blobRequest)