aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David G. Quintas <dgq@google.com>2017-01-25 20:32:52 -0800
committerGravatar GitHub <noreply@github.com>2017-01-25 20:32:52 -0800
commit0292bf617697119b84b68f8ea52ded8a0954ad17 (patch)
tree8fa3d67950da878c67c9efb678ff72d0b2ad096d
parent6f690f34831ac175a2c92d8838a5fc12ab8035b5 (diff)
parentd8e3e3d544036408dde6bd49f93666075de6d37a (diff)
Merge pull request #9464 from dgquintas/stalled_stream_ref_fix
Fixed stream ref issue on exhausted outgoing flow ctrl window
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c
index ef2010af7b..84554d327d 100644
--- a/src/core/ext/transport/chttp2/transport/writing.c
+++ b/src/core/ext/transport/chttp2/transport/writing.c
@@ -74,6 +74,15 @@ static void update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
GRPC_ERROR_UNREF(error);
}
+static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
+ gpr_atm count;
+ do {
+ count = gpr_atm_acq_load(&r->count);
+ if (count == 0) return false;
+ } while (!gpr_atm_rel_cas(&r->count, count, count + 1));
+ return true;
+}
+
bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t) {
grpc_chttp2_stream *s;
@@ -101,8 +110,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
if (t->outgoing_window > 0) {
while (grpc_chttp2_list_pop_stalled_by_transport(t, &s)) {
- grpc_chttp2_become_writable(exec_ctx, t, s, false,
- "transport.read_flow_control");
+ if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s) &&
+ stream_ref_if_not_destroyed(&s->refcount->refs)) {
+ grpc_chttp2_initiate_write(exec_ctx, t, false,
+ "transport.read_flow_control");
+ }
}
}