Skip to content

Commit

Permalink
Darin netlink events
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Apr 6, 2024
1 parent fc63ec9 commit 3fc633d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions monitor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var ErrNetlinkBanned = E.New(

func NewNetworkUpdateMonitor(logger logger.Logger) (NetworkUpdateMonitor, error) {
monitor := &networkUpdateMonitor{
routeUpdate: make(chan netlink.RouteUpdate, 2),
linkUpdate: make(chan netlink.LinkUpdate, 2),
routeUpdate: make(chan netlink.RouteUpdate, 100),
linkUpdate: make(chan netlink.LinkUpdate, 100),
close: make(chan struct{}),
logger: logger,
}
Expand Down Expand Up @@ -78,6 +78,15 @@ func (m *networkUpdateMonitor) loopUpdate() {
case <-m.routeUpdate:
case <-m.linkUpdate:
}
drain:
for {
select {
case <-m.routeUpdate:
case <-m.linkUpdate:
default:
break drain
}
}
m.emit()
select {
case <-m.close:
Expand Down

0 comments on commit 3fc633d

Please sign in to comment.