mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 09:23:09 -06:00
Correctly clean up timer
This commit is contained in:
parent
6c98aa7666
commit
59d99dcf3c
|
|
@ -79,13 +79,15 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
// Otherwise, we wait for the notifier to tell us if something *may* have
|
// Otherwise, we wait for the notifier to tell us if something *may* have
|
||||||
// happened. We loop in case it turns out that nothing did happen.
|
// happened. We loop in case it turns out that nothing did happen.
|
||||||
|
|
||||||
timeoutChan := time.After(syncReq.timeout) // case of timeout=0 is handled above
|
timer := time.NewTimer(syncReq.timeout) // case of timeout=0 is handled above
|
||||||
|
defer timer.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
// Wait for notifier to wake us up
|
// Wait for notifier to wake us up
|
||||||
case currPos = <-rp.makeNotifyChannel(*syncReq, currPos):
|
case currPos = <-rp.makeNotifyChannel(*syncReq, currPos):
|
||||||
// Or for timeout to expire
|
// Or for timeout to expire
|
||||||
case <-timeoutChan:
|
case <-timer.C:
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: 200,
|
Code: 200,
|
||||||
JSON: types.NewResponse(syncReq.since),
|
JSON: types.NewResponse(syncReq.since),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue