aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-11 14:24:34 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-15 14:24:15 -0700
commit134e92fafba1638121c3ddfee4c7e3d52404a374 (patch)
treea23b2b242898e906882707be69c9cdbd6ceedbc0 /src/core
parentfbac5f17b71cb2fc6b3b8f377dc1b896fdf952e0 (diff)
Move state update to ack, to prevent races
Conflicts: src/core/surface/call.c
Diffstat (limited to 'src/core')
-rw-r--r--src/core/surface/call.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index e1fef35fe7..7a30de5f33 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -588,6 +588,7 @@ static void call_on_done_send(void *pc, int success) {
lock(call);
if (call->last_send_contains & (1 << GRPC_IOREQ_SEND_INITIAL_METADATA)) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_INITIAL_METADATA, success);
+ call->write_state = WRITE_STATE_STARTED;
}
if (call->last_send_contains & (1 << GRPC_IOREQ_SEND_MESSAGE)) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_MESSAGE, success);
@@ -596,6 +597,10 @@ static void call_on_done_send(void *pc, int success) {
finish_ioreq_op(call, GRPC_IOREQ_SEND_TRAILING_METADATA, success);
finish_ioreq_op(call, GRPC_IOREQ_SEND_STATUS, success);
finish_ioreq_op(call, GRPC_IOREQ_SEND_CLOSE, 1);
+ call->write_state = WRITE_STATE_WRITE_CLOSED;
+ }
+ if (!success) {
+ call->write_state = WRITE_STATE_WRITE_CLOSED;
}
call->last_send_contains = 0;
call->sending = 0;
@@ -810,7 +815,6 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op) {
op->send_ops = &call->send_ops;
op->bind_pollset = grpc_cq_pollset(call->cq);
call->last_send_contains |= 1 << GRPC_IOREQ_SEND_INITIAL_METADATA;
- call->write_state = WRITE_STATE_STARTED;
call->send_initial_metadata_count = 0;
/* fall through intended */
case WRITE_STATE_STARTED:
@@ -826,7 +830,6 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op) {
op->is_last_send = 1;
op->send_ops = &call->send_ops;
call->last_send_contains |= 1 << GRPC_IOREQ_SEND_CLOSE;
- call->write_state = WRITE_STATE_WRITE_CLOSED;
if (!call->is_client) {
/* send trailing metadata */
data = call->request_data[GRPC_IOREQ_SEND_TRAILING_METADATA];