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()
|
this.transLock.Lock()
|
||||||
defer this.transLock.Unlock()
|
defer this.transLock.Unlock()
|
||||||
for _, trans := range this.transMap {
|
for _, trans := range this.transMap {
|
||||||
trans.Close()
|
trans.closeDontUnlist()
|
||||||
}
|
}
|
||||||
clear(this.transMap)
|
clear(this.transMap)
|
||||||
}()
|
}()
|
||||||
@ -163,9 +163,13 @@ type transA struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *transA) Close() error {
|
func (this *transA) Close() error {
|
||||||
this.incoming.Close()
|
err := this.closeDontUnlist()
|
||||||
this.parent.unlistTransactionSafe(this.ID())
|
this.parent.unlistTransactionSafe(this.ID())
|
||||||
return nil
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *transA) closeDontUnlist() error {
|
||||||
|
return this.incoming.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *transA) ID() int64 {
|
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) {
|
func (this *transA) Receive() (method uint16, data []byte, err error) {
|
||||||
message, ok := <- this.incoming.Receive()
|
receive := this.incoming.Receive()
|
||||||
if !ok {
|
if receive != nil {
|
||||||
if this.parent.err == nil {
|
if message, ok := <- receive; ok {
|
||||||
return 0, nil, fmt.Errorf("could not receive message: %w", io.EOF)
|
return message.method, message.payload, nil
|
||||||
} else {
|
|
||||||
return 0, nil, this.parent.err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 {
|
type incomingMessage struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user