Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/stats http handler is not concurrency-safe? #16

Open
cfergeau opened this issue Mar 25, 2021 · 0 comments
Open

/stats http handler is not concurrency-safe? #16

cfergeau opened this issue Mar 25, 2021 · 0 comments

Comments

@cfergeau
Copy link
Collaborator

func (n *VirtualNetwork) Mux() http.Handler has:

mux.HandleFunc("/stats", func(w http.ResponseWriter, r *http.Request) {                                                          
	_ = json.NewEncoder(w).Encode(statsAsJSON(n.networkSwitch.Sent, n.networkSwitch.Received, n.stack.Stats()))
})

The Sent and Received variables are modified using atomic functions, but I suspect they need to read through similar APIs for something thread-safe?

n.stack.Stats() is:

// Stats returns a mutable copy of the current stats.
//      
// This is not generally exported via the public interface, but is available
// internally.
func (s *Stack) Stats() tcpip.Stats {
        return s.stats
}

This does not seem to be something which is intended to be accessed safely from multiple threads?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant