-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
net: add writeQueueSize #44157
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
net: add writeQueueSize #44157
Conversation
|
Review requested:
|
ShogunPanda
left a comment
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!
7c1308d to
4277c46
Compare
4277c46 to
04b23b0
Compare
mcollina
left a comment
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
This comment was marked as outdated.
This comment was marked as outdated.
04cead9 to
342d0f6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
342d0f6 to
277a76f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
| // because the socket is connecting currently in libuv, so libuv will | ||
| // insert the write request into write queue, then we can get the | ||
| // size of write queue by `socket.writeQueueSize`. | ||
| socket.connecting = false; |
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 there a way to test the feature without this hack? I mean, how would socket.writeQueueSize be used in the real world? The test should simulate that.
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, it is difficult to write the test, and i think this test is not good.writeQueueSize means how many bytes are waiting to write in libuv. and add socket._handle.writeQueueSize to the count of bytesWritten maybe a good idea. I'll take a look later, thanks !
|
I think it makes more sense to undeprecate |
|
@pinca I've read the source code. I think 'bytesWritten' is equal to the length of all written bytes, which includes the data has been sent and data is waiting to be sent. And 'writeQueueSize' indicates the length of bytes waiting to be sent in Libuv. |
|
@theanarkh I was talking about diff --git a/lib/net.js b/lib/net.js
index eaa5e594e5..ce02019a75 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -637,7 +637,7 @@ ObjectDefineProperty(Socket.prototype, 'bufferSize', {
__proto__: null,
get: function() {
if (this._handle) {
- return this.writableLength;
+ return this._handle.writeQueueSize + this.writableLength;
}
}
});
instead of creating a new property. |
|
Oh. Thanks. |
|
It seems
I would just use I also think that |
|
This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open. |
add
writeQueueSizefor net.js.make -j4 test(UNIX), orvcbuild test(Windows) passes