mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-26 00:01:55 -06:00
Avoid race conditions, remove unreachable code
This commit is contained in:
parent
2999559982
commit
da215c2f1d
|
@ -80,6 +80,7 @@ func (p *InviteStreamProvider) IncrementalSync(
|
|||
if _, ok := req.Response.Rooms.Join[roomID]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
lr := types.NewLeaveResponse()
|
||||
h := sha256.Sum256(append([]byte(roomID), []byte(strconv.FormatInt(int64(to), 10))...))
|
||||
lr.Timeline.Events = append(lr.Timeline.Events, gomatrixserverlib.ClientEvent{
|
||||
|
|
|
@ -128,7 +128,6 @@ func ToToken(provider StreamProvider, position types.StreamPosition) types.Strea
|
|||
default:
|
||||
panic(fmt.Sprintf("unknown stream provider: %T", t))
|
||||
}
|
||||
return types.StreamingToken{}
|
||||
}
|
||||
|
||||
func IncrementalPositions(provider StreamProvider, current, since types.StreamingToken) (types.StreamPosition, types.StreamPosition) {
|
||||
|
@ -154,5 +153,4 @@ func IncrementalPositions(provider StreamProvider, current, since types.Streamin
|
|||
default:
|
||||
panic(fmt.Sprintf("unknown stream provider: %T", t))
|
||||
}
|
||||
return 0, 0
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
@ -101,6 +102,7 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
|
|||
Rooms: make(map[string]string), // Populated by the PDU stream
|
||||
WantFullState: wantFullState, //
|
||||
MembershipChanges: make(map[string]struct{}), // Populated by the PDU stream
|
||||
SyncMu: &sync.Mutex{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -326,6 +326,8 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
|
|||
succeeded = err == nil
|
||||
sqlutil.EndTransactionWithCheck(snapshot, &succeeded, &err)
|
||||
}()
|
||||
syncReq.SyncMu.Lock()
|
||||
defer syncReq.SyncMu.Unlock()
|
||||
return f(snapshot)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package types
|
|||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
@ -26,6 +27,7 @@ type SyncRequest struct {
|
|||
MembershipChanges map[string]struct{}
|
||||
// Updated by the PDU stream.
|
||||
IgnoredUsers IgnoredUsers
|
||||
SyncMu *sync.Mutex
|
||||
}
|
||||
|
||||
func (r *SyncRequest) IsRoomPresent(roomID string) bool {
|
||||
|
|
Loading…
Reference in a new issue