Skip to content

Conversation

@kevinkassimo
Copy link
Contributor

@kevinkassimo kevinkassimo commented Oct 4, 2018

Attempt to implement closeRead/closeWrite
Simulated shutdown(2) interface.

Also briefly implemented Conn.addr()

None => panic!("bad rid"),
Some(repr) => match repr {
Repr::TcpStream(ref mut f) => TcpStream::shutdown(f, how).unwrap(),
_ => panic!("Cannot shutdown"),
Copy link
Member

Choose a reason for hiding this comment

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

Looks good - nice.

@kevinkassimo kevinkassimo changed the title [WIP] Implement closeRead/closeWrite using TcpStream::shutdown & implement conn.addr() Implement closeRead/closeWrite using TcpStream::shutdown & implement conn.addr() Oct 4, 2018
src/resources.rs Outdated
assert!(r.is_some());
}

// no collision with unimplemented shutdown
Copy link
Member

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");
Copy link
Member

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() {
Copy link
Member

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() {
Copy link
Member

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
conn.close();
});

testPerm({ net: true }, async function netConnCloseRead() {
Copy link
Member

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() {
Copy link
Member

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;
}
Copy link
Member

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.

Copy link
Member

@ry ry left a 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

@kevinkassimo kevinkassimo changed the title Implement closeRead/closeWrite using TcpStream::shutdown & implement conn.addr() Implement closeRead/closeWrite using TcpStream::shutdown Oct 5, 2018
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";
Copy link
Member

@ry ry Oct 5, 2018

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?

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 941e27d into denoland:master Oct 5, 2018
ry added a commit to ry/deno that referenced this pull request Oct 12, 2018
- 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
@ry ry mentioned this pull request Oct 12, 2018
ry added a commit to ry/deno that referenced this pull request Oct 12, 2018
- 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
ry added a commit that referenced this pull request Oct 12, 2018
- 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
@kevinkassimo kevinkassimo deleted the net/shutdown branch December 27, 2019 07:52
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

Successfully merging this pull request may close these issues.

2 participants