Fetch an acknowledgement for each message that requested one

This fixes error handling when using lasting connections.

fixes #170
This commit is contained in:
Michael Stapelberg 2022-06-11 23:33:46 +02:00
parent 2025aec0d2
commit a346d51f53
1 changed files with 8 additions and 2 deletions

10
conn.go
View File

@ -182,8 +182,14 @@ func (cc *Conn) Flush() error {
return fmt.Errorf("SendMessages: %w", err)
}
if _, err := conn.Receive(); err != nil {
return fmt.Errorf("Receive: %w", err)
// Fetch the requested acknowledgement for each message we sent.
for _, msg := range cc.messages {
if msg.Header.Flags&netlink.Acknowledge == 0 {
continue // message did not request an acknowledgement
}
if _, err := conn.Receive(); err != nil {
return fmt.Errorf("conn.Receive: %w", err)
}
}
return nil