Put the loop and the IsEmpty() check back in sync handler

This commit is contained in:
Brendan Abolivier 2018-12-11 11:50:41 +00:00
parent bff549b94b
commit deb181ea50
No known key found for this signature in database
GPG key ID: 8EF1500759F70623

View file

@ -86,6 +86,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
userStreamListener := rp.notifier.GetListener(*syncReq) userStreamListener := rp.notifier.GetListener(*syncReq)
defer userStreamListener.Close() defer userStreamListener.Close()
for {
select { select {
// Wait for notifier to wake us up // Wait for notifier to wake us up
case <-userStreamListener.GetNotifyChannel(currPos): case <-userStreamListener.GetNotifyChannel(currPos):
@ -110,11 +111,14 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
return httputil.LogThenError(req, err) return httputil.LogThenError(req, err)
} }
if !syncData.IsEmpty() {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusOK, Code: http.StatusOK,
JSON: syncData, JSON: syncData,
} }
} }
}
}
func (rp *RequestPool) currentSyncForUser(req syncRequest, currentPos types.StreamPosition) (res *types.Response, err error) { func (rp *RequestPool) currentSyncForUser(req syncRequest, currentPos types.StreamPosition) (res *types.Response, err error) {
// TODO: handle ignored users // TODO: handle ignored users