// This can be called multiple times on a single FD.
// The net argument is a network name from the net package (e.g., "tcp"),
// or "file".
+// Set pollable to true if fd should be managed by runtime netpoll.
func (fd *FD) Init(net string, pollable bool) error {
// We don't actually care about the various network types.
if net == "file" {
// This can be called multiple times on a single FD.
// The net argument is a network name from the net package (e.g., "tcp"),
// or "file" or "console" or "dir".
-func (fd *FD) Init(net string) (string, error) {
+// Set pollable to true if fd should be managed by runtime netpoll.
+func (fd *FD) Init(net string, pollable bool) (string, error) {
if initErr != nil {
return "", initErr
}
}
var err error
- if !fd.isFile && !fd.isConsole && !fd.isDir {
+ if pollable {
// Only call init for a network socket.
// This means that we don't add files to the runtime poller.
// Adding files to the runtime poller can confuse matters
}
func (fd *netFD) init() error {
- errcall, err := fd.pfd.Init(fd.net)
+ errcall, err := fd.pfd.Init(fd.net, true)
if errcall != "" {
err = wrapSyscallError(errcall, err)
}
// Ignore initialization errors.
// Assume any problems will show up in later I/O.
- f.pfd.Init(kind)
+ f.pfd.Init(kind, false)
return f
}