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

pollfd fix, round 2 #12237

Merged
merged 8 commits into from
Jul 27, 2015
Merged

pollfd fix, round 2 #12237

merged 8 commits into from
Jul 27, 2015

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Jul 21, 2015

this is a rewrite of the poll_fd, poll_file, and watch_file APIs to more directly expose the libuv API and eliminate the callback legacy interface. since FDWatcher objects are now refcounted, this also solves #4401.

this replaces #7275

ping: @Keno

amitmurthy and others added 3 commits July 20, 2015 14:42
this eliminates the callback interface to the filesystem poll functions,
to be consistent with the changes to the rest of base

additionally, this exposes the full libuv API for watch_file and
poll_file, rather than returning inconsistent return values from these two functions

this fixes FDWatcher to ensure that it is unique for any given fd,
(to avoid a libuv assertion). it must be manually closed before closing
fd, or the applications behavior is undefined.
@vtjnash vtjnash added the domain:io Involving the I/O subsystem: libuv, read, write, etc. label Jul 21, 2015
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 21, 2015

cross-ref: this will resolve some of #10293

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 21, 2015

this closes #7840 (when merged)

@@ -595,6 +597,7 @@ function _uv_hook_close(t::Timer)
unpreserve_handle(t)
disassociate_julia_struct(t)
t.handle = C_NULL
notify(t.cond)
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix is the cause of the warning in the repl.jl test: the Timer callback on line 100 of test/repl.jl is supposed to accept an argument t

@JeffBezanson
Copy link
Sponsor Member

Awesome, this is a relief!

I believe the only piece of #10293 left is SingleAsyncWork?

end

@unix_only _get_osfhandle(fd::RawFD) = fd
@windows_only _get_osfhandle(fd::RawFD) = WindowsRawSocket(ccall(:_get_osfhandle,Ptr{Void},(Cint,),fd.fd))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this'll need to be qualified with Libc. now anywhere it's used, like base/stream.jl and base/mmap.jl

@@ -1,52 +1,90 @@
# This file is a part of Julia. License is MIT: http:https://julialang.org/license

@unix_only begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this? msvcrt has _pipe but it has extra arguments: https://msdn.microsoft.com/en-us/library/aa298531(v=vs.60).aspx

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the eventual goal is to get this test running on windows too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a bad goal, but will need to account for different spellings/api of posix functions - unless libuv has wrappers for all of these, which I think is one of the things we've been meaning to do upstream?

also works-around an issue where libuv timers could return too early on windows by several milliseconds

this provides a general-purpose socketpair implementation on windows, for use in the tests and otherwise (although uv_pipe_link is recommended for any case where you don't explicitly need a WSA2 SOCKET)
…ows] Libc module (also use them to provide better errors in the tests)

these belong in Libc since the are the windows counterparts to errno/strerror which are documented and exported in Libc
@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 24, 2015

bump. this passes CI everywhere now...

Monitor a file for changes by polling every `interval_seconds` seconds for `seconds` seconds. A return value of true indicates
the file changed, a return value of false indicates a timeout.
Monitor a file for changes by polling every ``interval_seconds`` seconds until a change occurs or ``timeout_s`` seconds have elapsed.
The `timeout_s` should be a long interval; the default is 5.007 seconds.
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should say interval instead of timeout_s.

@ViralBShah ViralBShah added this to the 0.4.0 milestone Jul 25, 2015
@ViralBShah
Copy link
Member

Marking this as 0.4 - assuming this is is done and long standing, and we should get it in.

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 27, 2015

bump. i'll merge this later today.

vtjnash added a commit that referenced this pull request Jul 27, 2015
@vtjnash vtjnash merged commit 39bd1fc into master Jul 27, 2015
@vtjnash vtjnash deleted the jn/pollfd_fix2 branch July 27, 2015 16:10
@amitmurthy
Copy link
Contributor

Awesome. 👍

@tkelman
Copy link
Contributor

tkelman commented Jul 29, 2015

travis failure here https://gist.github.com/tkelman/96b21860b35454115373, are we back to timings that are too picky for busy low-memory VM's?

@amitmurthy
Copy link
Contributor

OTOH, in this case it does seem like it caught an actual bug. The poll call should not have returned before intvl seconds.

@tkelman
Copy link
Contributor

tkelman commented Jul 31, 2015

Another failure: https://travis-ci.org/JuliaLang/julia/jobs/73427729

exception on 5: ERROR: LoadError: test failed: 0.1 <= 0.099903232
 in expression: intvl <= t_elapsed
 in yieldto at ./task.jl:24
 in wait at ./task.jl:313
 in wait at ./task.jl:228
 in wait at ./task.jl:61
 in sync_end at ./task.jl:340
 in anonymous at no file:348
 in include_string at loading.jl:158
 in include_from_node1 at ./loading.jl:200
 in runtests at /tmp/julia/share/julia/test/testdefs.jl:173
 in anonymous at multi.jl:909
 in run_work_thunk at multi.jl:648
 in anonymous at task.jl:909
while loading /tmp/julia/share/julia/test/pollfd.jl, in expression starting on line 65
    From worker 3:       * bitarray              in  90.72 seconds
    From worker 4:       * mpfr                  in   4.91 seconds
    From worker 2:       * subarray              in 353.43 seconds
ERROR: LoadError: LoadError: test failed: 0.1 <= 0.099903232
 in expression: intvl <= t_elapsed
 in anonymous at task.jl:1442
while loading /tmp/julia/share/julia/test/pollfd.jl, in expression starting on line 65
while loading /tmp/julia/share/julia/test/runtests.jl, in expression starting on line 5
    From worker 5:       * pollfd          

@tkelman
Copy link
Contributor

tkelman commented Aug 11, 2015

@timholy
Copy link
Sponsor Member

timholy commented Aug 12, 2015

Another pollfd failure on AppVeyor:
image
in #12560.

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Aug 12, 2015

i'm not really sure what that test is doing in the pollfd.jl file, since it is testing the functionality of one-shot Timers, not any of this code

@JeffBezanson @Keno is 0.2 sec sometimes not enough for a 0.01 sec timer to trigger? (added in 7f4c2de)

@tkelman
Copy link
Contributor

tkelman commented Aug 13, 2015

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Aug 19, 2015

latest travis failure on #12463 (https://travis-ci.org/JuliaLang/julia/builds/76174785) was also due to Jeff's new test for Timers there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants