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

stream_base: expose bytesRead getter #6284

Closed
wants to merge 6 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Apr 19, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

stream_base

Description of change

This will provide bytesRead data on consumed sockets.

Fix: #3021

This will provide `bytesRead` data on consumed sockets.

Fix: nodejs#3021
@indutny
Copy link
Member Author

indutny commented Apr 19, 2016

cc @trevnorris

@indutny
Copy link
Member Author

indutny commented Apr 19, 2016

@mscdex mscdex added c++ Issues and PRs that require attention from people who are familiar with C++. net Issues and PRs related to the net subsystem. labels Apr 19, 2016
@@ -182,6 +184,9 @@ class StreamResource {
Callback<AfterWriteCb> after_write_cb_;
Callback<AllocCb> alloc_cb_;
Callback<ReadCb> read_cb_;
int bytes_read_;
Copy link
Member

Choose a reason for hiding this comment

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

Why int instead of size_t?

Copy link
Member

Choose a reason for hiding this comment

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

Come to think of it, it should be uint64_t. Both int and size_t can overflow after 2 or 4 GB, which isn't out of the ordinary.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to uint_64, int would likely overflow very quickly

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, with some explicit conversions.

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

@bnoordhuis should be fixed now, PTAL

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

@@ -112,6 +111,10 @@ function initSocketHandle(self) {
}
}


const BYTES_READ = Symbol('bytesRead');
Copy link
Member

Choose a reason for hiding this comment

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

I think the naming preference is something like kBytesRead

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it?

lib/readline.js:const KEYPRESS_DECODER = Symbol('keypress-decoder');
lib/readline.js:const ESCAPE_DECODER = Symbol('escape-decoder');
lib/repl.js:exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy');
lib/repl.js:exports.REPL_MODE_STRICT = Symbol('repl-strict');
lib/repl.js:exports.REPL_MODE_MAGIC = Symbol('repl-magic');

Copy link
Member

Choose a reason for hiding this comment

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

Ok, yep, I've seen comments both ways but the code doesn't lie ;-)

indutny added 2 commits April 20, 2016 11:55
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.
@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

const PropertyCallbackInfo<Value>& args) {
StreamBase* wrap = Unwrap<Base>(args.Holder());

// int64_t -> double. 53bits is enough for all real cases.
Copy link
Member

Choose a reason for hiding this comment

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

uint64_t -> double

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, thanks!

@bnoordhuis
Copy link
Member

LGTM with nit.

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

Unrelated failure on ARM:


Test Name
Duration
Age
 53 - test-http-agent.js 

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

Landed in 6198472 and 8636af1, thank you!

@indutny indutny closed this Apr 20, 2016
@indutny indutny deleted the fix/gh-3021 branch April 20, 2016 16:43
indutny added a commit that referenced this pull request Apr 20, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
indutny added a commit that referenced this pull request Apr 20, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This was referenced Apr 21, 2016
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: nodejs#3021
PR-URL: nodejs#6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: nodejs#6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
jasnell pushed a commit that referenced this pull request Apr 26, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
jasnell pushed a commit that referenced this pull request Apr 26, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@MylesBorins
Copy link
Contributor

@indutny this isn't landing cleanly on v4.x... would you be able to backport?

@indutny
Copy link
Member Author

indutny commented May 20, 2016

Will do a backport.

indutny added a commit to indutny/io.js that referenced this pull request May 20, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: nodejs#3021
PR-URL: nodejs#6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
indutny added a commit to indutny/io.js that referenced this pull request May 20, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: nodejs#6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@indutny indutny mentioned this pull request May 20, 2016
4 tasks
@indutny
Copy link
Member Author

indutny commented May 20, 2016

@thealphanerd here you go #6903

MylesBorins pushed a commit that referenced this pull request Jun 1, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Jun 1, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Jun 23, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Jun 23, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
This will provide `bytesRead` data on consumed sockets.

Fix: #3021
PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
`Object.prototype.__defineGetter__` is deprecated now, use
`Object.defineProperty` instead.

PR-URL: #6284
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@MylesBorins MylesBorins mentioned this pull request Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http/server: request.socket.bytesRead always 0 for IncomingMessage
5 participants