-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Implement closeRead/closeWrite using TcpStream::shutdown #903
Conversation
None => panic!("bad rid"), | ||
Some(repr) => match repr { | ||
Repr::TcpStream(ref mut f) => TcpStream::shutdown(f, how).unwrap(), | ||
_ => panic!("Cannot shutdown"), |
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.
Looks good - nice.
src/resources.rs
Outdated
@@ -79,6 +81,21 @@ impl Resource { | |||
let r = table.remove(&self.rid); | |||
assert!(r.is_some()); | |||
} | |||
|
|||
// no collision with unimplemented shutdown |
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.
What does this mean?
} | ||
assert(!!err); | ||
assertEqual(err.kind, deno.ErrorKind.NotConnected); | ||
assertEqual(err.name, "NotConnected"); |
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.
Nice. Thank you.
js/net_test.ts
Outdated
conn.close(); | ||
}); | ||
|
||
testPerm({ net: true }, async function netConnDupCloseWriteFailure() { |
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.
Please rename to netDoubleCloseWrite()
"dup" has special meaning in this context (see dup(2))
js/net_test.ts
Outdated
conn.close(); | ||
}); | ||
|
||
testPerm({ net: true }, async function netConnDupCloseReadFailure() { |
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.
Rename to netDoubleCloseRead
js/net_test.ts
Outdated
@@ -35,3 +35,115 @@ testPerm({ net: true }, async function netDialListen() { | |||
listener.close(); | |||
conn.close(); | |||
}); | |||
|
|||
testPerm({ net: true }, async function netConnCloseRead() { |
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.
Rename to netCloseReadSuccess()
js/net_test.ts
Outdated
conn.close(); | ||
}); | ||
|
||
testPerm({ net: true }, async function netConnCloseWrite() { |
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.
Rename to netCloseWriteSuccess
js/net.ts
Outdated
export interface Addr { | ||
network: Network; | ||
address: string; | ||
} |
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.
Can you please leave the Addr changes out of this PR? I'd like to discuss them separately from shutdown.
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.
looks good - just a few comments
9cb594b
to
4f06636
Compare
@@ -1,7 +1,8 @@ | |||
// Copyright 2018 the Deno authors. All rights reserved. MIT license. | |||
|
|||
import * as deno from "deno"; | |||
import { testPerm, assert, assertEqual, deferred } from "./test_util.ts"; | |||
import { testPerm, assert, assertEqual } from "./test_util.ts"; | |||
import { deferred } from "./util.ts"; |
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.
Cool! I forgot about this when I suggested it - but this is only newly possible because of your work in #859.
js/net_test.ts
runs inside of Deno, but js/util.ts
runs inside of Node/rollup. But now we are able to seamlessly load util.ts
in Deno too.
cc @kitsonk - can compiler_test.ts work like this too?
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.
LGTM
- Add --types command line flag. - Add metrics() - Add redirect follow feature denoland#934 - Fix clearTimer bug denoland#942 - Improve error printing denoland#935 - Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser, ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker - Fix silent death on double await denoland#919 - Add Conn.closeRead() and Conn.closeWrite() denoland#903
- Fix promise reject issue (denoland#936) - Add --types command line flag. - Add metrics() - Add redirect follow feature denoland#934 - Fix clearTimer bug denoland#942 - Improve error printing denoland#935 - Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser, ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker - Fix silent death on double await denoland#919 - Add Conn.closeRead() and Conn.closeWrite() denoland#903
- Fix promise reject issue (#936) - Add --types command line flag. - Add metrics() - Add redirect follow feature #934 - Fix clearTimer bug #942 - Improve error printing #935 - Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser, ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker - Fix silent death on double await #919 - Add Conn.closeRead() and Conn.closeWrite() #903
Attempt to implement
closeRead/closeWrite
Simulated
shutdown(2)
interface.Also briefly implemented
Conn.addr()