Compare commits
No commits in common. "5b42030f9dda26a364338dfbb82d70ed803c91bb" and "4647f91abe074daa06b36b6cc760f5d870c10f8e" have entirely different histories.
5b42030f9d
...
4647f91abe
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.closeDontUnlist()
|
||||
trans.Close()
|
||||
}
|
||||
clear(this.transMap)
|
||||
}()
|
||||
@ -163,13 +163,9 @@ type transA struct {
|
||||
}
|
||||
|
||||
func (this *transA) Close() error {
|
||||
err := this.closeDontUnlist()
|
||||
this.incoming.Close()
|
||||
this.parent.unlistTransactionSafe(this.ID())
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *transA) closeDontUnlist() error {
|
||||
return this.incoming.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *transA) ID() int64 {
|
||||
@ -181,18 +177,15 @@ func (this *transA) Send(method uint16, data []byte) error {
|
||||
}
|
||||
|
||||
func (this *transA) Receive() (method uint16, data []byte, err error) {
|
||||
receive := this.incoming.Receive()
|
||||
if receive != nil {
|
||||
if message, ok := <- receive; ok {
|
||||
return message.method, message.payload, nil
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if this.parent.err == nil {
|
||||
return 0, nil, fmt.Errorf("could not receive message: %w", io.EOF)
|
||||
} else {
|
||||
return 0, nil, this.parent.err
|
||||
}
|
||||
return message.method, message.payload, nil
|
||||
}
|
||||
|
||||
type incomingMessage struct {
|
||||
|
Loading…
Reference in New Issue
Block a user