summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go6
-rw-r--r--utils.go3
-rw-r--r--ws.go17
3 files changed, 1 insertions, 25 deletions
diff --git a/main.go b/main.go
index fafeda9..412caa3 100644
--- a/main.go
+++ b/main.go
@@ -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))
diff --git a/utils.go b/utils.go
index 9cc83bb..3628c80 100644
--- a/utils.go
+++ b/utils.go
@@ -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.
diff --git a/ws.go b/ws.go
index ec626a3..0bccee4 100644
--- a/ws.go
+++ b/ws.go
@@ -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.