Fix zero value of currPos may be used in OnIncomingSyncRequest

Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
Cnly 2019-06-27 05:00:48 +08:00
parent 6fd1c21207
commit 274db2fbaf

View file

@ -63,9 +63,11 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
"timeout": syncReq.timeout,
}).Info("Incoming /sync request")
currPos := rp.notifier.CurrentPosition()
// If this is an initial sync or timeout=0 we return immediately
if syncReq.since == nil || syncReq.timeout == 0 {
syncData, err = rp.currentSyncForUser(*syncReq, rp.notifier.CurrentPosition())
syncData, err = rp.currentSyncForUser(*syncReq, currPos)
if err != nil {
return httputil.LogThenError(req, err)
}
@ -90,7 +92,6 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
// respond with, so we skip the return an go back to waiting for content to
// be sent down or the request timing out.
var hasTimedOut bool
var currPos types.SyncPosition
sincePos := *syncReq.since
for {
select {