this will never block, can be called while holding router.Lock
(msgBytes []byte, debugStr string)
| 412 | |
| 413 | // this will never block, can be called while holding router.Lock |
| 414 | func (router *WshRouter) queueUpstreamMessage(msgBytes []byte, debugStr string) { |
| 415 | _, upstream := router.getUpstreamClient() |
| 416 | if upstream == nil { |
| 417 | return |
| 418 | } |
| 419 | router.upstreamBufLock.Lock() |
| 420 | defer router.upstreamBufLock.Unlock() |
| 421 | router.upstreamBuf = append(router.upstreamBuf, messageWrap{msgBytes: msgBytes, debugStr: debugStr}) |
| 422 | if !router.upstreamLoopStarted { |
| 423 | router.upstreamLoopStarted = true |
| 424 | go router.runUpstreamBufferLoop() |
| 425 | } |
| 426 | router.upstreamBufCond.Signal() |
| 427 | } |
| 428 | |
| 429 | func (router *WshRouter) runUpstreamBufferLoop() { |
| 430 | defer func() { |
no test coverage detected