-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
inspector: zero out structure members #8536
Conversation
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. Maybe make the structs DISALLOW_COPY_AND_ASSIGN while you're here.
I've added DISALLOW_COPY_AND_ASSIGN. Then it showed that inspector socket instance needs a cleanup to be reused - so I decided that it would be best if inspector_accept did a reset, instead of expecting a clean instance. Please take another look. |
Sorry, forgot to run the linter. I uploaded a fixed version. |
inspector->buffer.clear(); | ||
inspector->ws_mode = false; | ||
inspector->shutting_down = false; | ||
inspector->connection_eof = 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.
This looks like it should be a inspector_socket_s
method.
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.
Thank you for the review. I introduced the function... But that pushed the struct to class territory too far for me :)
I changed the struct to class, renamed it appropriately and added the namespace. In fairness, other inspector_* functions need to become member functions as well and the state needs to be made private, etc.
But I am currently working on a complex refactoring that will significantly change this class (I'm hoping to remove libuv interactions) so I don't see much value in doing a comprehensive change right now...
Please take a look at updated CL.
inspector_socket_t* inspector = | ||
reinterpret_cast<inspector_socket_t*>(parser->data); | ||
InspectorSocket* inspector = | ||
reinterpret_cast<InspectorSocket*>(parser->data); |
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.
Maybe switch to static_cast while here?
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.
Done
public: | ||
InspectorSocket() : data(nullptr), http_parsing_state(nullptr), | ||
ws_state(nullptr), buffer(0), ws_mode(false), | ||
shutting_down(false), connection_eof(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.
Indentation is off here.
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.
Done.
handshake_cb callback); | ||
|
||
void inspector_close(struct inspector_socket_s* inspector, | ||
void inspector_close(struct InspectorSocket* inspector, |
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 drop the struct
keywords?
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.
Done
@@ -95,7 +97,7 @@ static bool connected_cb(inspector_socket_t* socket, | |||
static void on_new_connection(uv_stream_t* server, int status) { | |||
GTEST_ASSERT_EQ(0, status); | |||
connected = true; | |||
inspector_accept(server, reinterpret_cast<inspector_socket_t*>(server->data), | |||
inspector_accept(server, reinterpret_cast<InspectorSocket*>(server->data), |
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.
static_cast?
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.
Done.
Thank you for the review. I updated the code, please take another look. |
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.
Ctor has to be added as memset to 0 is no longer an option, since the structure now has std::vector member. Attemp at fixing #8155 (so far I was not able to repro it)
CI after rebase: https://ci.nodejs.org/job/node-test-pull-request/4159/ |
Thanks, landed as bc1ebd6. |
Ctor has to be added as memset to 0 is no longer an option, since the structure now has std::vector member. Attempt at fixing nodejs#8155 (so far I was not able to repro it) PR-URL: nodejs#8536 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Change is internal to inspector.
Description of change
Ctor has to be added as memset to 0 is no longer an option, since
the structure now has std::vector member.
This is an attempt at guessing a fix for #8155 - so far I was not able to repro it.