-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change file descriptor to be blocking. #4
Conversation
@@ -41,6 +41,7 @@ func getRawFtraceChan(fp FileProvider, cpu int, doneCh <-chan bool) (<-chan []by | |||
|
|||
for { | |||
var buf = make([]byte, syscall.Getpagesize()) | |||
syscall.SetNonblock(int(f.(*os.File).Fd()), false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -41,6 +41,7 @@ func getRawFtraceChan(fp FileProvider, cpu int, doneCh <-chan bool) (<-chan []by | |||
|
|||
for { | |||
var buf = make([]byte, syscall.Getpagesize()) | |||
syscall.SetNonblock(int(f.(*os.File).Fd()), false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this all we need? I thought I tried this out. Then Reading
golang/go#22939 and https://go-review.googlesource.com/c/go/+/100077/13
I was under the impression we needed to change the os.Open in file.go
to something closer to os.NewFile
then make the call to syscall.SetNonblock
(golang/go#22939 (comment))
I tried replacing Open with OpenFile, passing in O_NONBLOCK. I also tried setting `syscall.SetNonblock(fd, false)` immediately after the OpenFile and earlier in the loop.
I think the go runtime is adjusting the state of the file descriptor. For example (https://golang.org/src/os/file_unix.go <https://golang.org/src/os/file_unix.go>) changes it when you call Fd(), why not in other places?
It is by making the Read() call /blocking/ that our previous behavior is preserved, as we’ve always been working with blocking files (pipes) and the Select() call to switch between them.
But I admit I’m fairly perplexed by it as well.
… On Feb 1, 2019, at 5:33 PM, Seth ***@***.***> wrote:
@Setheck commented on this pull request.
In ftrace/raw.go <#4 (comment)>:
> @@ -41,6 +41,7 @@ func getRawFtraceChan(fp FileProvider, cpu int, doneCh <-chan bool) (<-chan []by
for {
var buf = make([]byte, syscall.Getpagesize())
+ syscall.SetNonblock(int(f.(*os.File).Fd()), false)
Is this all we need? I thought I tried this out. Then Reading
golang/go#22939 <golang/go#22939> and https://go-review.googlesource.com/c/go/+/100077/13 <https://go-review.googlesource.com/c/go/+/100077/13>
I was under the impression we needed to change the os.Open in file.go to something closer to os.NewFile then make the call to syscall.SetNonblock (golang/go#22939 (comment) <golang/go#22939 (comment)>)
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub <#4 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAAysFzs32upWapOc1Rh7s0879RaPx5Eks5vJOrQgaJpZM4afS1t>.
|
…d pipes as non-blocking - and we ultimately want to force blocking behavior.
This appears to be changed via the go runtime, as we need to set the file descriptor type prior to each read call.
gather
seems to function the same in go1.8 or go 1.11.