Compare commits
2 Commits
4647f91abe
...
5b42030f9d
Author | SHA1 | Date | |
---|---|---|---|
5b42030f9d | |||
4daccca66a |
27
metadapta.go
27
metadapta.go
@ -104,7 +104,7 @@ func (this *a) receive() {
|
||||
this.transLock.Lock()
|
||||
defer this.transLock.Unlock()
|
||||
for _, trans := range this.transMap {
|
||||
trans.Close()
|
||||
trans.closeDontUnlist()
|
||||
}
|
||||
clear(this.transMap)
|
||||
}()
|
||||
@ -163,9 +163,13 @@ type transA struct {
|
||||
}
|
||||
|
||||
func (this *transA) Close() error {
|
||||
this.incoming.Close()
|
||||
err := this.closeDontUnlist()
|
||||
this.parent.unlistTransactionSafe(this.ID())
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *transA) closeDontUnlist() error {
|
||||
return this.incoming.Close()
|
||||
}
|
||||
|
||||
func (this *transA) ID() int64 {
|
||||
@ -177,15 +181,18 @@ func (this *transA) Send(method uint16, data []byte) error {
|
||||
}
|
||||
|
||||
func (this *transA) Receive() (method uint16, data []byte, err error) {
|
||||
message, ok := <- this.incoming.Receive()
|
||||
if !ok {
|
||||
if this.parent.err == nil {
|
||||
return 0, nil, fmt.Errorf("could not receive message: %w", io.EOF)
|
||||
} else {
|
||||
return 0, nil, this.parent.err
|
||||
receive := this.incoming.Receive()
|
||||
if receive != nil {
|
||||
if message, ok := <- receive; ok {
|
||||
return message.method, message.payload, nil
|
||||
}
|
||||
}
|
||||
return message.method, message.payload, nil
|
||||
|
||||
if this.parent.err == nil {
|
||||
return 0, nil, fmt.Errorf("could not receive message: %w", io.EOF)
|
||||
} else {
|
||||
return 0, nil, this.parent.err
|
||||
}
|
||||
}
|
||||
|
||||
type incomingMessage struct {
|
||||
|
Loading…
Reference in New Issue
Block a user