mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Dont lock the player list all the time when serving the GeoJSON over /players.
This commit is contained in:
parent
c918b538db
commit
28fc4d0734
@ -86,10 +86,12 @@ func (ps *players) run() {
|
||||
|
||||
func (ps *players) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
var pls []*player
|
||||
ps.mu.RLock()
|
||||
defer ps.mu.RUnlock()
|
||||
pls = ps.pls
|
||||
ps.mu.RUnlock()
|
||||
encoder := json.NewEncoder(rw)
|
||||
if err := encoder.Encode(ps.pls); err != nil {
|
||||
if err := encoder.Encode(pls); err != nil {
|
||||
log.Printf("error: sending JSON failed: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user