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

Start would reset fd on HandleRead to blocking lead to set deadliner doesn't work #11

Open
ackratos opened this issue Mar 26, 2019 · 0 comments

Comments

@ackratos
Copy link

ackratos commented Mar 26, 2019

you set non blocking here for handle read:

easygo/netpoll/handle.go

Lines 91 to 93 in 0c8322a

if err = setNonblock(desc.fd(), true); err != nil {
return nil, os.NewSyscallError("setnonblock", err)
}

but on poller.Start(), the call to fd() would set underlying file to blocking mode again.

return p.Add(desc.fd(), events, n, func(kev Kevent) {


// Fd returns the integer Unix file descriptor referencing the open file.
// The file descriptor is valid only until f.Close is called or f is garbage collected.
// On Unix systems this will cause the SetDeadline methods to stop working.
func (f *File) Fd() uintptr {
	if f == nil {
		return ^(uintptr(0))
	}

	// If we put the file descriptor into nonblocking mode,
	// then set it to blocking mode before we return it,
	// because historically we have always returned a descriptor
	// opened in blocking mode. The File will continue to work,
	// but any blocking operation will tie up a thread.
	if f.nonblock {
		f.pfd.SetBlocking()
	}

	return uintptr(f.pfd.Sysfd)
}

This caused set deadliner doesn't work on conn owned by poller

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

1 participant