diff options
author | 2017-11-30 15:02:15 -0800 | |
---|---|---|
committer | 2017-11-30 15:09:45 -0800 | |
commit | 445c5664e0572daa7b07fdde0e4959f0deeb803f (patch) | |
tree | 1923f13fc03cc7177eece77f0075d8aa949a08b0 /test | |
parent | 02df4abc866d0205f4ab3bab5df1036a83d118e0 (diff) |
Add special cases and some comments
Diffstat (limited to 'test')
-rw-r--r-- | test/core/end2end/fixtures/http_proxy_fixture.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index c6a8abf40a..f46edac6d7 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -77,6 +77,9 @@ struct grpc_end2end_http_proxy { #define CLIENT_EP_FAIL (CLIENT_EP_READ_FAIL | CLIENT_EP_WRITE_FAIL) #define EP_FAIL (SERVER_EP_FAIL | CLIENT_EP_FAIL) +// proxy_connection structure is only accessed in the closures which are all +// scheduled under the same combiner lock. So there is is no need for a mutex to +// protect this structure. typedef struct proxy_connection { grpc_end2end_http_proxy* proxy; @@ -94,6 +97,8 @@ typedef struct proxy_connection { grpc_pollset_set* pollset_set; + // NOTE: All the closures execute under proxy->combiner lock. Which means + // there will not be any data-races between the closures grpc_closure on_read_request_done; grpc_closure on_server_connect_done; grpc_closure on_write_response_done; @@ -241,8 +246,13 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { - proxy_connection_failed(exec_ctx, conn, CLIENT_EP_READ_FAIL, - "HTTP proxy client read", error); + // Report a read failure on the client endpoint. If there is no pending + // server write, then shutdown the server endpoint as well. + proxy_connection_failed( + exec_ctx, conn, + (conn->server_is_writing ? CLIENT_EP_READ_FAIL + : (CLIENT_EP_READ_FAIL | SERVER_EP_FAIL)), + "HTTP proxy client read", error); return; } // If there is already a pending write (i.e., server_write_buffer is @@ -274,8 +284,13 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { - proxy_connection_failed(exec_ctx, conn, SERVER_EP_READ_FAIL, - "HTTP proxy server read", error); + // Report a read failure on the server end point. If there is no pending + // write to the client, then shutdown the client endpoint as well. + proxy_connection_failed( + exec_ctx, conn, + (conn->client_is_writing ? SERVER_EP_READ_FAIL + : (SERVER_EP_READ_FAIL | CLIENT_EP_FAIL)), + "HTTP proxy server read", error); return; } // If there is already a pending write (i.e., client_write_buffer is |