-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Conversation
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021
cc @trevnorris |
@@ -182,6 +184,9 @@ class StreamResource { | |||
Callback<AfterWriteCb> after_write_cb_; | |||
Callback<AllocCb> alloc_cb_; | |||
Callback<ReadCb> read_cb_; | |||
int bytes_read_; |
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.
Why int instead of size_t?
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.
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.
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.
+1 to uint_64
, int
would likely overflow very quickly
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.
Ack, with some explicit conversions.
@bnoordhuis should be fixed now, PTAL |
@@ -112,6 +111,10 @@ function initSocketHandle(self) { | |||
} | |||
} | |||
|
|||
|
|||
const BYTES_READ = Symbol('bytesRead'); |
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.
I think the naming preference is something like kBytesRead
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.
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');
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.
Ok, yep, I've seen comments both ways but the code doesn't lie ;-)
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead.
const PropertyCallbackInfo<Value>& args) { | ||
StreamBase* wrap = Unwrap<Base>(args.Holder()); | ||
|
||
// int64_t -> double. 53bits is enough for all real cases. |
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.
uint64_t -> double
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.
Ack, thanks!
LGTM with nit. |
Unrelated failure on ARM:
|
Landed in 6198472 and 8636af1, thank you! |
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021 PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@indutny this isn't landing cleanly on v4.x... would you be able to backport? |
Will do a backport. |
This will provide `bytesRead` data on consumed sockets. Fix: nodejs#3021 PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: nodejs#6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@thealphanerd here you go #6903 |
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Checklist
Affected core subsystem(s)
stream_base
Description of change
This will provide
bytesRead
data on consumed sockets.Fix: #3021