aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/transport')
-rw-r--r--src/core/transport/chttp2_transport.c30
-rw-r--r--src/core/transport/stream_op.c31
2 files changed, 39 insertions, 22 deletions
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index dae1b1e1b7..885838ec5d 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -823,24 +823,26 @@ static void unlock(transport *t) {
finish_reads(t);
/* gather any callbacks that need to be made */
- if (!t->calling_back && cb) {
+ if (!t->calling_back) {
perform_callbacks = prepare_callbacks(t);
if (perform_callbacks) {
t->calling_back = 1;
}
- if (t->error_state == ERROR_STATE_SEEN && !t->writing) {
- call_closed = 1;
- t->calling_back = 1;
- t->cb = NULL; /* no more callbacks */
- t->error_state = ERROR_STATE_NOTIFIED;
- }
- if (t->num_pending_goaways) {
- goaways = t->pending_goaways;
- num_goaways = t->num_pending_goaways;
- t->pending_goaways = NULL;
- t->num_pending_goaways = 0;
- t->cap_pending_goaways = 0;
- t->calling_back = 1;
+ if (cb) {
+ if (t->error_state == ERROR_STATE_SEEN && !t->writing && !t->calling_back) {
+ call_closed = 1;
+ t->calling_back = 1;
+ t->cb = NULL; /* no more callbacks */
+ t->error_state = ERROR_STATE_NOTIFIED;
+ }
+ if (t->num_pending_goaways) {
+ goaways = t->pending_goaways;
+ num_goaways = t->num_pending_goaways;
+ t->pending_goaways = NULL;
+ t->num_pending_goaways = 0;
+ t->cap_pending_goaways = 0;
+ t->calling_back = 1;
+ }
}
}
diff --git a/src/core/transport/stream_op.c b/src/core/transport/stream_op.c
index e1a75adcb6..8996ecac35 100644
--- a/src/core/transport/stream_op.c
+++ b/src/core/transport/stream_op.c
@@ -59,15 +59,30 @@ void grpc_sopb_reset(grpc_stream_op_buffer *sopb) {
}
void grpc_sopb_swap(grpc_stream_op_buffer *a, grpc_stream_op_buffer *b) {
- grpc_stream_op_buffer temp = *a;
- *a = *b;
- *b = temp;
-
- if (a->ops == b->inlined_ops) {
+ GPR_SWAP(size_t, a->nops, b->nops);
+ GPR_SWAP(size_t, a->capacity, b->capacity);
+
+ if (a->ops == a->inlined_ops) {
+ if (b->ops == b->inlined_ops) {
+ /* swap contents of inlined buffer */
+ gpr_slice temp[GRPC_SOPB_INLINE_ELEMENTS];
+ memcpy(temp, a->ops, b->nops * sizeof(grpc_stream_op));
+ memcpy(a->ops, b->ops, a->nops * sizeof(grpc_stream_op));
+ memcpy(b->ops, temp, b->nops * sizeof(grpc_stream_op));
+ } else {
+ /* a is inlined, b is not - copy a inlined into b, fix pointers */
+ a->ops = b->ops;
+ b->ops = b->inlined_ops;
+ memcpy(b->ops, a->inlined_ops, b->nops * sizeof(grpc_stream_op));
+ }
+ } else if (b->ops == b->inlined_ops) {
+ /* b is inlined, a is not - copy b inlined int a, fix pointers */
+ b->ops = a->ops;
a->ops = a->inlined_ops;
- }
- if (b->ops == a->inlined_ops) {
- b->ops = b->inlined_ops;
+ memcpy(a->ops, b->inlined_ops, a->nops * sizeof(grpc_stream_op));
+ } else {
+ /* no inlining: easy swap */
+ GPR_SWAP(grpc_stream_op *, a->ops, b->ops);
}
}