Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

"github.com/matrix-org/complement-crypto/internal/api"
"github.com/matrix-org/complement-crypto/internal/api/rust/matrix_sdk_ffi"
"github.com/matrix-org/complement-crypto/internal/api/rust/matrix_sdk_base"
"github.com/matrix-org/complement-crypto/internal/api/rust/matrix_sdk_ffi"
"github.com/matrix-org/complement/ct"
"github.com/matrix-org/complement/helpers"
"github.com/matrix-org/complement/must"
Expand Down Expand Up @@ -697,7 +697,12 @@ func (c *RustClient) ensureListening(t ct.TestLike, roomID string) {
return false
}
if room := c.findRoom(t, roomID); room != nil {
c.ensureListening(t, roomID) // this should work now
// Do this asynchronously because adding a timeline listener is done synchronously
// which will cause "signal arrived during cgo execution" if it happens within
// this rooms listener callback.
go func() {
c.ensureListening(t, roomID) // this should work now
}()
return true
}
return false
Expand All @@ -717,8 +722,9 @@ func (c *RustClient) ensureListening(t ct.TestLike, roomID string) {
// _before_ we have set the initial entries in the timeline. This would cause a lost update
// as setting the initial entries clears the timeline, which can then result in test flakes.
waiter := helpers.NewWaiter()
c.rooms[roomID].timeline = make([]*api.Event, 0)
result := mustGetTimeline(t, r).AddListener(&timelineListener{fn: func(diff []*matrix_sdk_ffi.TimelineDiff) {
waiter.Waitf(t, 5*time.Second, "timed out waiting for Timeline.AddListener to return")
defer waiter.Finish()
timeline := c.rooms[roomID].timeline
var newEvents []*api.Event
c.Logf(t, "[%s]AddTimelineListener[%s] TimelineDiff len=%d", c.userID, roomID, len(diff))
Expand Down Expand Up @@ -821,9 +827,9 @@ func (c *RustClient) ensureListening(t ct.TestLike, roomID string) {
}
}})
c.rooms[roomID].stream = result
c.rooms[roomID].timeline = make([]*api.Event, 0)
c.Logf(t, "[%s]AddTimelineListener[%s] set up", c.userID, roomID)
waiter.Finish()
waiter.Waitf(t, 5*time.Second, "timed out waiting for Timeline.AddListener to return")

}

type timelineWaiter struct {
Expand Down
Loading