Skip to content

Commit

Permalink
Merge pull request bettercap#19 from QuantumIntegration/upstream_bugf…
Browse files Browse the repository at this point in the history
…ix/handle-eitr-and-eagain

Add EAGAIN and EINTR handling in hci mainloop
  • Loading branch information
evilsocket committed May 14, 2021
2 parents 7a3c1c5 + 122824a commit 4e07ff8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions linux/hci.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/bettercap/gatt/linux/cmd"
"github.com/bettercap/gatt/linux/evt"
"github.com/bettercap/gatt/linux/util"
"golang.org/x/sys/unix"
)

type HCI struct {
Expand Down Expand Up @@ -192,6 +193,10 @@ func (h *HCI) mainLoop() {
// log.Printf("hci.mainLoop Read(%d)", len(b))
n, err := h.d.Read(b)
if err != nil {
if err == unix.EAGAIN || err == unix.EINTR {
// We should just try again since partial or no data was available
continue
}
log.Printf("mainloop err: %v", err)
return
}
Expand Down

0 comments on commit 4e07ff8

Please sign in to comment.