Fix race condition in transport API
Specifically:
Receiving trailing and initial metadata had to be published in
lock-step.
=> If we wanted trailing metadata, we might not get initial metadata processed
until messages arrived.
=> Compression code had no idea what codec to use.
To fix it, publish initial metadata as soon as it's ready (this is a
transport API change).
Requires changes to grpc_call to ensure ordering in processing initial
metadata and messages (one may be delayed).
Exposed at least some bugs in C++ where we never read initial metadata.
I expect at least one more similar bug.
diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c
index 43eee04..1aa2720 100644
--- a/src/core/channel/http_client_filter.c
+++ b/src/core/channel/http_client_filter.c
@@ -127,8 +127,8 @@
if (op->recv_initial_metadata != NULL) {
/* substitute our callback for the higher callback */
calld->recv_initial_metadata = op->recv_initial_metadata;
- calld->on_done_recv = op->on_complete;
- op->on_complete = &calld->hc_on_recv;
+ calld->on_done_recv = op->recv_initial_metadata_ready;
+ op->recv_initial_metadata_ready = &calld->hc_on_recv;
}
}