Fix roomserver deadlock (#380)

Move the mutex lock outside the loop so that we don't lock up if there is more
than one event
main
Richard van der Hoff 2017-12-19 11:29:49 +00:00 committed by GitHub
parent ec30d143cd
commit 899f267c47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -61,11 +61,10 @@ func (r *RoomserverInputAPI) InputRoomEvents(
request *api.InputRoomEventsRequest,
response *api.InputRoomEventsResponse,
) error {
// We lock as processRoomEvent can only be called once at a time
r.mutex.Lock()
defer r.mutex.Unlock()
for i := range request.InputRoomEvents {
// We lock as processRoomEvent can ony be called once at a time
r.mutex.Lock()
defer r.mutex.Unlock()
if err := processRoomEvent(ctx, r.DB, r, request.InputRoomEvents[i]); err != nil {
return err
}