summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config.go3
-rw-r--r--docs/cca.scfg.example4
-rw-r--r--ws.go11
3 files changed, 14 insertions, 4 deletions
diff --git a/config.go b/config.go
index bc75c70..fb962c9 100644
--- a/config.go
+++ b/config.go
@@ -68,6 +68,7 @@ var configWithPointers struct {
Secret *string `scfg:"secret"`
} `scfg:"auth"`
Perf struct {
+ SendQ *int `scfg:"sendq"`
MessageArgumentsCap *int `scfg:"msg_args_cap"`
MessageBytesCap *int `scfg:"msg_bytes_cap"`
ReadHeaderTimeout *int `scfg:"read_header_timeout"`
@@ -96,6 +97,7 @@ var config struct {
Secret string
}
Perf struct {
+ SendQ int
MessageArgumentsCap int
MessageBytesCap int
ReadHeaderTimeout int
@@ -127,6 +129,7 @@ func fetchConfig(path string) error {
config.Auth.Jwks = *(configWithPointers.Auth.Jwks)
config.Auth.Token = *(configWithPointers.Auth.Token)
config.Auth.Secret = *(configWithPointers.Auth.Secret)
+ config.Perf.SendQ = *(configWithPointers.Perf.SendQ)
config.Perf.MessageArgumentsCap = *(configWithPointers.Perf.MessageArgumentsCap)
config.Perf.MessageBytesCap = *(configWithPointers.Perf.MessageBytesCap)
config.Perf.ReadHeaderTimeout = *(configWithPointers.Perf.ReadHeaderTimeout)
diff --git a/docs/cca.scfg.example b/docs/cca.scfg.example
index d787878..95f39b9 100644
--- a/docs/cca.scfg.example
+++ b/docs/cca.scfg.example
@@ -66,6 +66,10 @@ auth {
# The following block contains some tweaks for performance.
perf {
+ # How long should the send queue be? This is implemented as the
+ # buffer number for a Go channel.
+ sendq 10
+
# How many arguments' space should we initially allocate for each
# message?
msg_args_cap 4
diff --git a/ws.go b/ws.go
index 6cc809a..90356d4 100644
--- a/ws.go
+++ b/ws.go
@@ -236,9 +236,12 @@ func setupChanPool() error {
func propagate(msg string) {
chanPoolLock.RLock()
defer chanPoolLock.RUnlock()
- for _, v := range chanPool {
- *v <- msg
- /* TODO: This may block */
+ for k, v := range chanPool {
+ select {
+ case *v <- msg:
+ default:
+ log.Println("WARNING: SendQ exceeded for " + k) /* TODO: Handle this better */
+ }
}
/* TODO: Any possible errors? */
}
@@ -256,7 +259,7 @@ func handleConn(
/*
* TODO: Check for potential race conditions in chanPool handling
*/
- send := make(chan string)
+ send := make(chan string, config.Perf.SendQ)
chanPoolLock.Lock()
func() {
defer chanPoolLock.Unlock()