Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventErr #9

Open
damanloox opened this issue Dec 15, 2018 · 1 comment
Open

EventErr #9

damanloox opened this issue Dec 15, 2018 · 1 comment

Comments

@damanloox
Copy link

c, err := l.Accept()
desc := netpoll.Must(netpoll.HandleRead(c))
poller.Start(desc, func(ev netpoll.Event) {
  if ev&netpoll.EventHup != 0 || ev&netpoll.EventErr != 0 {
    // close etc
  }
  go doSomething(c)
}

Why the code above doesn't "catch" connection error (eg. timeout)?
Also - when I close connection c inside doSomething(c) - the poller doesn't seem to catch that either - which leads me to a question - how to stop poller on error inside doSomething()?

@wI2L
Copy link

wI2L commented Mar 4, 2019

The file descriptor of the *Desc instance returned by HandleRead is a copy of the connection file descriptor (see net.TCPConn File() method doc). If you close the connection itself, the file description it represents still exists and is not automatically removed from the poller instance. Instead you should either close connection and the *Desc instance or explicitly use the Poller Stop method to detach the FD from the Poller then close connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants