Skip to content

Commit

Permalink
change to atomic.Uint64
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman authored and ycombinator committed Sep 20, 2024
1 parent 039b658 commit 05b3b30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions testing/fleetservertest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func NewRouter(handlers *Handlers) *mux.Router {
route.Handler.
ServeHTTP(ww, r)
handlers.logFn("[%s] DONE %d - %s %s %s %s %d\n",
requestID, ww.statusCode, r.Method, r.URL, r.Proto, r.RemoteAddr, atomic.LoadUint64(&ww.byteCount))
requestID, ww.statusCode, r.Method, r.URL, r.Proto, r.RemoteAddr, ww.byteCount.Load())
}))
}

Expand Down Expand Up @@ -505,7 +505,7 @@ func updateLocalMetaAgentID(data []byte, agentID string) ([]byte, error) {
type statusResponseWriter struct {
w http.ResponseWriter
statusCode int
byteCount uint64
byteCount atomic.Uint64
}

func (s *statusResponseWriter) Header() http.Header {
Expand All @@ -514,7 +514,7 @@ func (s *statusResponseWriter) Header() http.Header {

func (s *statusResponseWriter) Write(bs []byte) (int, error) {
n, err := s.w.Write(bs)
atomic.AddUint64(&s.byteCount, uint64(n))
s.byteCount.Add(uint64(n))
return n, err
}

Expand Down

0 comments on commit 05b3b30

Please sign in to comment.