Skip to content
Snippets Groups Projects
Commit 4cdcd12f authored by Mark D. Roth's avatar Mark D. Roth
Browse files

Fix locking bug in HTTP CONNECT handshaker.

parent 09ee8d02
No related branches found
No related tags found
No related merge requests found
...@@ -86,9 +86,9 @@ static void http_connect_handshaker_unref(http_connect_handshaker* handshaker) { ...@@ -86,9 +86,9 @@ static void http_connect_handshaker_unref(http_connect_handshaker* handshaker) {
static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
http_connect_handshaker* handshaker = arg; http_connect_handshaker* handshaker = arg;
gpr_mu_lock(&handshaker->mu);
if (error != GRPC_ERROR_NONE || handshaker->args == NULL) { if (error != GRPC_ERROR_NONE || handshaker->args == NULL) {
// If the write failed, invoke the callback immediately with the error. // If the write failed, invoke the callback immediately with the error.
gpr_mu_lock(&handshaker->mu);
grpc_exec_ctx_sched(exec_ctx, handshaker->on_handshake_done, grpc_exec_ctx_sched(exec_ctx, handshaker->on_handshake_done,
GRPC_ERROR_REF(error), NULL); GRPC_ERROR_REF(error), NULL);
handshaker->args = NULL; handshaker->args = NULL;
...@@ -97,7 +97,6 @@ static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg, ...@@ -97,7 +97,6 @@ static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
} else { } else {
// Otherwise, read the response. // Otherwise, read the response.
// The read callback inherits our ref to the handshaker. // The read callback inherits our ref to the handshaker.
gpr_mu_lock(&handshaker->mu);
grpc_endpoint_read(exec_ctx, handshaker->args->endpoint, grpc_endpoint_read(exec_ctx, handshaker->args->endpoint,
handshaker->args->read_buffer, handshaker->args->read_buffer,
&handshaker->response_read_closure); &handshaker->response_read_closure);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment