diff options
-rw-r--r-- | main.go | 6 | ||||
-rw-r--r-- | utils.go | 3 | ||||
-rw-r--r-- | ws.go | 17 |
3 files changed, 1 insertions, 25 deletions
@@ -60,12 +60,6 @@ func main() { log.Fatal(err) } - log.Println("Setting up context cancellation connection pool") - err = setupCancelPool() - if err != nil { - log.Fatal(err) - } - log.Println("Registering static handle") fs := http.FileServer(http.Dir(config.Static)) http.Handle("/static/", http.StripPrefix("/static/", fs)) @@ -23,14 +23,11 @@ package main import ( "crypto/rand" "encoding/base64" - "errors" "fmt" "log" "net/http" ) -var errUnexpectedRace = errors.New("unexpected race condition") - /* * Write a string to a http.ResponseWriter, setting the Content-Type and status * code. @@ -264,7 +264,7 @@ var ( /* * Note that the key for cancelPool is a userID rather than a sessionID */ - cancelPool map[string](*context.CancelFunc) + cancelPool = make(map[string](*context.CancelFunc)) /* * Normal Go maps are not thread safe, so we protect large cancelPool * operations such as addition and deletion under a RWMutex. @@ -272,21 +272,6 @@ var ( cancelPoolLock sync.RWMutex ) -func setupCancelPool() error { - /* - * It would be unusual for this function to run concurrently with - * anything else that modifies cancelPool, so we fail when the lock is - * unsuccessful. - */ - r := cancelPoolLock.TryLock() - if !r { - return fmt.Errorf("cannot set up cancelPool: %w", errUnexpectedRace) - } - defer cancelPoolLock.Unlock() - cancelPool = make(map[string](*context.CancelFunc)) - return nil -} - /* * Only call this when it is okay for propagation to fail, such as in course * number updates. Failures are currently ignored. |