Fix METADAPT-A not receiving more than one message
This commit is contained in:
parent
659bcecbe6
commit
5e885a0bd3
16
metadapta.go
16
metadapta.go
@ -102,7 +102,7 @@ func (this *a) receive() {
|
|||||||
defer func() {
|
defer func() {
|
||||||
this.underlying.Close()
|
this.underlying.Close()
|
||||||
this.transLock.Lock()
|
this.transLock.Lock()
|
||||||
defer this.transLock.Lock()
|
defer this.transLock.Unlock()
|
||||||
for _, trans := range this.transMap {
|
for _, trans := range this.transMap {
|
||||||
trans.Close()
|
trans.Close()
|
||||||
}
|
}
|
||||||
@ -124,22 +124,30 @@ func (this *a) receive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *a) receiveMultiplex(transID int64, method uint16, payload []byte) error {
|
func (this *a) receiveMultiplex(transID int64, method uint16, payload []byte) error {
|
||||||
if transID == 0 || this.party == partyFromTransID(transID) {
|
if transID == 0 { return ErrMessageMalformed }
|
||||||
return ErrMessageMalformed
|
|
||||||
}
|
|
||||||
|
|
||||||
|
trans, err := func() (*transA, error) {
|
||||||
this.transLock.Lock()
|
this.transLock.Lock()
|
||||||
defer this.transLock.Unlock()
|
defer this.transLock.Unlock()
|
||||||
|
|
||||||
trans, ok := this.transMap[transID]
|
trans, ok := this.transMap[transID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
// it is forbidden for the other party to initiate a transaction
|
||||||
|
// with an ID from this party
|
||||||
|
if this.party == partyFromTransID(transID) {
|
||||||
|
return nil, ErrMessageMalformed
|
||||||
|
}
|
||||||
trans = &transA {
|
trans = &transA {
|
||||||
parent: this,
|
parent: this,
|
||||||
id: transID,
|
id: transID,
|
||||||
incoming: usync.NewGate[incomingMessage](),
|
incoming: usync.NewGate[incomingMessage](),
|
||||||
}
|
}
|
||||||
|
this.transMap[transID] = trans
|
||||||
this.transChan <- trans
|
this.transChan <- trans
|
||||||
}
|
}
|
||||||
|
return trans, nil
|
||||||
|
}()
|
||||||
|
if err != nil { return err }
|
||||||
|
|
||||||
trans.incoming.Send(incomingMessage {
|
trans.incoming.Send(incomingMessage {
|
||||||
method: method,
|
method: method,
|
||||||
|
Loading…
Reference in New Issue
Block a user