-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Handle uv_read_start
error
#9721
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ use rt::uv::uvll; | |
use rt::uv::uvll::*; | ||
use rt::uv::{AllocCallback, ConnectionCallback, ReadCallback, UdpReceiveCallback, UdpSendCallback}; | ||
use rt::uv::{Loop, Watcher, Request, UvError, Buf, NativeHandle, NullCallback, | ||
status_to_maybe_uv_error}; | ||
status_to_maybe_uv_error, vec_to_uv_buf}; | ||
use rt::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr}; | ||
use vec; | ||
use str; | ||
|
@@ -147,7 +147,18 @@ impl StreamWatcher { | |
data.read_cb = Some(cb); | ||
} | ||
|
||
unsafe { uvll::read_start(self.native_handle(), alloc_cb, read_cb); } | ||
let ret = unsafe { uvll::read_start(self.native_handle(), alloc_cb, read_cb) }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a generic problem with our uv bindings. Do you know of the scope of the remaining callsites which need to handle this return value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm working on do scheduler.deschedule_running_task_and_then |_, task| {
do call_uv_something_with_callback |_watcher, status| {
let scheduler: ~Scheduler = Local::take();
scheduler.resume_blocked_task_immediately(task_cell.take());
}
} can be problematic if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd have to take a look myself, but it sounds like this needs more of a general refactoring than fixing on a case-by-case basis. What it this currently blocking on windows? Is it basically error cases aren't handled correctly, or is the behavior much more serious than that? It's another one of those things where the runtime is in some serious need for some love right now, and it'd be sad to just pile more stuff on it instead of fixing the root causes while we still can. That being said, if this is urgent, then this otherwise looks good to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More explanation on tests: So, I think we have to check return value of assert_eq!(0, uvll::write(req.native_handle(), self.native_handle(), [buf], write_cb)); however in some cases the assertion can be invalid in non-fatal case. This is why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm beginning to think that this probably isn't the right place to address these concerns, let's let this request through and then go back to check all the existing uv bindings. |
||
|
||
if ret != 0 { | ||
// uvll::read_start failed, so read_cb will not be called. | ||
// Call it manually for scheduling. | ||
call_read_cb(self.native_handle(), ret as ssize_t); | ||
} | ||
|
||
fn call_read_cb(stream: *uvll::uv_stream_t, errno: ssize_t) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unfortunate :( Is it because the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. Just to not put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine to put |
||
#[fixed_stack_segment]; #[inline(never)]; | ||
read_cb(stream, errno, vec_to_uv_buf(~[])); | ||
} | ||
|
||
extern fn alloc_cb(stream: *uvll::uv_stream_t, suggested_size: size_t) -> Buf { | ||
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(stream); | ||
|
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.
This seems sad that this happens on windows and not unix. I'd be more in favor of just swallowing all errors instead of testing for some errors on some platforms and none on others. It still seems icky to swallow errors though...
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.
Do you know why we're not raising an error unix, and only on windows? Is it because on unix when libuv calls the callback from the second read that there's no error?
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.
Yes. I'm not sure if it is really intended, so reported the behavior at joyent/libuv#948.