Fix another "deadlock" in METADAPT-A
What fucking idiot go developer decided recv from a nil channel locks the entire program. ?????? just have it return zero value and false.
This commit is contained in:
parent
4daccca66a
commit
5b42030f9d
17
metadapta.go
17
metadapta.go
@ -181,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