Skip to content

Commit b05ce84

Browse files
Eugene OstroukhovMyles Borins
Eugene Ostroukhov
authored and
Myles Borins
committed
inspector: zero out structure members
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 #8155 (so far I was not able to repro it) PR-URL: #8536 Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
1 parent 0b90ff7 commit b05ce84

File tree

4 files changed

+104
-77
lines changed

4 files changed

+104
-77
lines changed

src/inspector_agent.cc

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#endif
3333

3434
namespace node {
35+
namespace inspector {
3536
namespace {
3637

3738
const char TAG_CONNECT[] = "#connect";
@@ -51,7 +52,7 @@ void PrintDebuggerReadyMessage(int port) {
5152
fflush(stderr);
5253
}
5354

54-
bool AcceptsConnection(inspector_socket_t* socket, const std::string& path) {
55+
bool AcceptsConnection(InspectorSocket* socket, const std::string& path) {
5556
return StringEqualNoCaseN(path.c_str(), DEVTOOLS_PATH,
5657
sizeof(DEVTOOLS_PATH) - 1);
5758
}
@@ -62,11 +63,11 @@ void Escape(std::string* string) {
6263
}
6364
}
6465

65-
void DisposeInspector(inspector_socket_t* socket, int status) {
66+
void DisposeInspector(InspectorSocket* socket, int status) {
6667
delete socket;
6768
}
6869

69-
void DisconnectAndDisposeIO(inspector_socket_t* socket) {
70+
void DisconnectAndDisposeIO(InspectorSocket* socket) {
7071
if (socket) {
7172
inspector_close(socket, DisposeInspector);
7273
}
@@ -77,7 +78,7 @@ void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) {
7778
buf->len = len;
7879
}
7980

80-
void SendHttpResponse(inspector_socket_t* socket, const char* response,
81+
void SendHttpResponse(InspectorSocket* socket, const char* response,
8182
size_t len) {
8283
const char HEADERS[] = "HTTP/1.0 200 OK\r\n"
8384
"Content-Type: application/json; charset=UTF-8\r\n"
@@ -90,7 +91,7 @@ void SendHttpResponse(inspector_socket_t* socket, const char* response,
9091
inspector_write(socket, response, len);
9192
}
9293

93-
void SendVersionResponse(inspector_socket_t* socket) {
94+
void SendVersionResponse(InspectorSocket* socket) {
9495
const char VERSION_RESPONSE_TEMPLATE[] =
9596
"[ {"
9697
" \"Browser\": \"node.js/%s\","
@@ -117,7 +118,7 @@ std::string GetProcessTitle() {
117118
}
118119
}
119120

120-
void SendTargentsListResponse(inspector_socket_t* socket,
121+
void SendTargentsListResponse(InspectorSocket* socket,
121122
const std::string& script_name_,
122123
const std::string& script_path_,
123124
int port) {
@@ -169,7 +170,7 @@ const char* match_path_segment(const char* path, const char* expected) {
169170
return nullptr;
170171
}
171172

172-
bool RespondToGet(inspector_socket_t* socket, const std::string& script_name_,
173+
bool RespondToGet(InspectorSocket* socket, const std::string& script_name_,
173174
const std::string& script_path_, const std::string& path,
174175
int port) {
175176
const char* command = match_path_segment(path.c_str(), "/json");
@@ -192,8 +193,6 @@ bool RespondToGet(inspector_socket_t* socket, const std::string& script_name_,
192193

193194
} // namespace
194195

195-
namespace inspector {
196-
197196

198197
class V8NodeInspector;
199198

@@ -220,16 +219,16 @@ class AgentImpl {
220219

221220
static void ThreadCbIO(void* agent);
222221
static void OnSocketConnectionIO(uv_stream_t* server, int status);
223-
static bool OnInspectorHandshakeIO(inspector_socket_t* socket,
222+
static bool OnInspectorHandshakeIO(InspectorSocket* socket,
224223
enum inspector_handshake_event state,
225224
const std::string& path);
226225
static void WriteCbIO(uv_async_t* async);
227226

228227
void InstallInspectorOnProcess();
229228

230229
void WorkerRunIO();
231-
void OnInspectorConnectionIO(inspector_socket_t* socket);
232-
void OnRemoteDataIO(inspector_socket_t* stream, ssize_t read,
230+
void OnInspectorConnectionIO(InspectorSocket* socket);
231+
void OnRemoteDataIO(InspectorSocket* stream, ssize_t read,
233232
const uv_buf_t* b);
234233
void SetConnected(bool connected);
235234
void DispatchMessages();
@@ -255,7 +254,7 @@ class AgentImpl {
255254

256255
uv_async_t* data_written_;
257256
uv_async_t io_thread_req_;
258-
inspector_socket_t* client_socket_;
257+
InspectorSocket* client_socket_;
259258
V8NodeInspector* inspector_;
260259
v8::Platform* platform_;
261260
MessageQueue incoming_message_queue_;
@@ -281,7 +280,7 @@ void InterruptCallback(v8::Isolate*, void* agent) {
281280
}
282281

283282
void DataCallback(uv_stream_t* stream, ssize_t read, const uv_buf_t* buf) {
284-
inspector_socket_t* socket = inspector_from_stream(stream);
283+
InspectorSocket* socket = inspector_from_stream(stream);
285284
static_cast<AgentImpl*>(socket->data)->OnRemoteDataIO(socket, read, buf);
286285
}
287286

@@ -594,7 +593,7 @@ void AgentImpl::ThreadCbIO(void* agent) {
594593
// static
595594
void AgentImpl::OnSocketConnectionIO(uv_stream_t* server, int status) {
596595
if (status == 0) {
597-
inspector_socket_t* socket = new inspector_socket_t();
596+
InspectorSocket* socket = new InspectorSocket();
598597
socket->data = server->data;
599598
if (inspector_accept(server, socket,
600599
AgentImpl::OnInspectorHandshakeIO) != 0) {
@@ -604,7 +603,7 @@ void AgentImpl::OnSocketConnectionIO(uv_stream_t* server, int status) {
604603
}
605604

606605
// static
607-
bool AgentImpl::OnInspectorHandshakeIO(inspector_socket_t* socket,
606+
bool AgentImpl::OnInspectorHandshakeIO(InspectorSocket* socket,
608607
enum inspector_handshake_event state,
609608
const std::string& path) {
610609
AgentImpl* agent = static_cast<AgentImpl*>(socket->data);
@@ -626,7 +625,7 @@ bool AgentImpl::OnInspectorHandshakeIO(inspector_socket_t* socket,
626625
}
627626
}
628627

629-
void AgentImpl::OnRemoteDataIO(inspector_socket_t* socket,
628+
void AgentImpl::OnRemoteDataIO(InspectorSocket* socket,
630629
ssize_t read,
631630
const uv_buf_t* buf) {
632631
Mutex::ScopedLock scoped_lock(pause_lock_);
@@ -660,7 +659,7 @@ void AgentImpl::OnRemoteDataIO(inspector_socket_t* socket,
660659
// static
661660
void AgentImpl::WriteCbIO(uv_async_t* async) {
662661
AgentImpl* agent = static_cast<AgentImpl*>(async->data);
663-
inspector_socket_t* socket = agent->client_socket_;
662+
InspectorSocket* socket = agent->client_socket_;
664663
if (socket) {
665664
MessageQueue outgoing_messages;
666665
agent->SwapBehindLock(&agent->outgoing_message_queue_, &outgoing_messages);
@@ -741,7 +740,7 @@ void AgentImpl::PostIncomingMessage(const String16& message) {
741740
}
742741
}
743742

744-
void AgentImpl::OnInspectorConnectionIO(inspector_socket_t* socket) {
743+
void AgentImpl::OnInspectorConnectionIO(InspectorSocket* socket) {
745744
if (client_socket_) {
746745
DisconnectAndDisposeIO(socket);
747746
return;

0 commit comments

Comments
 (0)