aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-28 10:02:07 -0700
committerGravatar GitHub <noreply@github.com>2017-04-28 10:02:07 -0700
commita9236bc4a1585f587da6f35897205d3479ed619a (patch)
treeb3ad5a0ed8a68b9eb8a172e40740e0b72948e37c
parentffa7473602fe3bd863d13a8317a349cb9de46845 (diff)
parent1c2332b0c1edfdcd5746939feaabc0904475d7ea (diff)
Merge pull request #10824 from ctiller/proxy2
Fix potential memory leak, cleanup some code
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c
index 4f5f41e9b0..1da8cf69cb 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.c
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c
@@ -277,13 +277,10 @@ static void compress_start_transport_stream_op_batch(
GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0);
if (op->cancel_stream) {
- gpr_atm cur;
GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error);
- do {
- cur = gpr_atm_acq_load(&calld->send_initial_metadata_state);
- } while (!gpr_atm_rel_cas(
- &calld->send_initial_metadata_state, cur,
- CANCELLED_BIT | (gpr_atm)op->payload->cancel_stream.cancel_error));
+ gpr_atm cur = gpr_atm_full_xchg(
+ &calld->send_initial_metadata_state,
+ CANCELLED_BIT | (gpr_atm)op->payload->cancel_stream.cancel_error);
switch (cur) {
case HAS_COMPRESSION_ALGORITHM:
case NO_COMPRESSION_ALGORITHM:
@@ -311,13 +308,18 @@ static void compress_start_transport_stream_op_batch(
grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
return;
}
- gpr_atm cur = gpr_atm_acq_load(&calld->send_initial_metadata_state);
+ gpr_atm cur;
+ retry_send_im:
+ cur = gpr_atm_acq_load(&calld->send_initial_metadata_state);
GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM &&
cur != NO_COMPRESSION_ALGORITHM);
if ((cur & CANCELLED_BIT) == 0) {
- gpr_atm_rel_store(&calld->send_initial_metadata_state,
- has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM
- : NO_COMPRESSION_ALGORITHM);
+ if (!gpr_atm_rel_cas(&calld->send_initial_metadata_state, cur,
+ has_compression_algorithm
+ ? HAS_COMPRESSION_ALGORITHM
+ : NO_COMPRESSION_ALGORITHM)) {
+ goto retry_send_im;
+ }
if (cur != INITIAL_METADATA_UNSEEN) {
grpc_call_next_op(exec_ctx, elem,
(grpc_transport_stream_op_batch *)cur);