Fix message duplication due to a race-condition
This commit is contained in:
parent
06929747d6
commit
6292303a31
3 changed files with 8 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ easybridge
|
||||||
config.json
|
config.json
|
||||||
registration.yaml
|
registration.yaml
|
||||||
easybridge.db
|
easybridge.db
|
||||||
|
__pycache__
|
||||||
|
|
|
@ -453,6 +453,9 @@ func (a *Account) eventInternal(event *Event) error {
|
||||||
|
|
||||||
var cache_key string
|
var cache_key string
|
||||||
if event.Id != "" {
|
if event.Id != "" {
|
||||||
|
dbLockSlot(mx_room_id)
|
||||||
|
defer dbUnlockSlot(mx_room_id)
|
||||||
|
|
||||||
// If the event has an ID, make sure it is processed only once
|
// If the event has an ID, make sure it is processed only once
|
||||||
cache_key = fmt.Sprintf("%s/event_seen/%s/%s",
|
cache_key = fmt.Sprintf("%s/event_seen/%s/%s",
|
||||||
a.Protocol, mx_room_id, event.Id)
|
a.Protocol, mx_room_id, event.Id)
|
||||||
|
|
|
@ -165,6 +165,10 @@ func handleTxnEvent(e *mxlib.Event) error {
|
||||||
if acct != nil {
|
if acct != nil {
|
||||||
ev.Author = acct.Conn.User()
|
ev.Author = acct.Conn.User()
|
||||||
ev.Room = room.RoomID
|
ev.Room = room.RoomID
|
||||||
|
|
||||||
|
dbLockSlot(e.RoomId)
|
||||||
|
defer dbUnlockSlot(e.RoomId)
|
||||||
|
|
||||||
created_ev_id, err := acct.Conn.Send(ev)
|
created_ev_id, err := acct.Conn.Send(ev)
|
||||||
if err == nil && created_ev_id != "" {
|
if err == nil && created_ev_id != "" {
|
||||||
cache_key := fmt.Sprintf("%s/event_seen/%s/%s",
|
cache_key := fmt.Sprintf("%s/event_seen/%s/%s",
|
||||||
|
|
Loading…
Reference in a new issue