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/surface/server.c b/src/core/surface/server.c
index 42cffcc..fb5e0d4 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -596,8 +596,8 @@
if (op->recv_initial_metadata != NULL) {
calld->recv_initial_metadata = op->recv_initial_metadata;
- calld->on_done_recv_initial_metadata = op->on_complete;
- op->on_complete = &calld->server_on_recv_initial_metadata;
+ calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready;
+ op->recv_initial_metadata_ready = &calld->server_on_recv_initial_metadata;
}
}