Skip to content

EventErr #9

Open
Open

Description

@damanloox
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()?

Activity

  1. wI2L commented on Mar 4, 2019

    @wI2L

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions