whenever appropriate so as to avoid any unintentional free-before-use
problems.
Potential performance issue: this triggers an additional allocation
for each Async call initiation, along with the cost of ref-counting
shared_ptr . But this is worth it for the additional safety provided
here without any change to the exposed C++ 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.