diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-01 15:04:31 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-01 15:04:31 -0700 |
commit | 248a5a024cee11060770eeb7431d1ce780c1c4dc (patch) | |
tree | 27abc4bf957727d025a79a5f8d4738733dcd1289 /src/core | |
parent | f037011b1f6d89705a631fd08524f0a0b5611c65 (diff) | |
parent | 1aa4bc08534a6284640e8cbf83db47dc2eb5b92e (diff) |
Merge github.com:grpc/grpc into tis-but-thy-name
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/resolve_address_posix.c | 2 | ||||
-rw-r--r-- | src/core/surface/call.c | 28 |
3 files changed, 19 insertions, 13 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 2075c43945..e8c24c772a 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -74,6 +74,7 @@ static void freelist_fd(grpc_fd *fd) { gpr_mu_lock(&fd_freelist_mu); fd->freelist_next = fd_freelist; fd_freelist = fd; + grpc_iomgr_unregister_object(&fd->iomgr_object); gpr_mu_unlock(&fd_freelist_mu); } @@ -139,7 +140,6 @@ static void unref_by(grpc_fd *fd, int n) { #endif old = gpr_atm_full_fetch_add(&fd->refst, -n); if (old == n) { - grpc_iomgr_unregister_object(&fd->iomgr_object); freelist_fd(fd); } else { GPR_ASSERT(old > n); diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c index 20d8c58eb4..dbf884c769 100644 --- a/src/core/iomgr/resolve_address_posix.c +++ b/src/core/iomgr/resolve_address_posix.c @@ -155,9 +155,9 @@ static void do_request(void *rp) { grpc_resolve_cb cb = r->cb; gpr_free(r->name); gpr_free(r->default_port); + cb(arg, resolved); grpc_iomgr_unregister_object(&r->iomgr_object); gpr_free(r); - cb(arg, resolved); } void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 8550056bcb..ae1b215767 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -160,6 +160,8 @@ struct grpc_call { gpr_uint8 bound_pollset; /* is an error status set */ gpr_uint8 error_status_set; + /** should the alarm be cancelled */ + gpr_uint8 cancel_alarm; /* flags with bits corresponding to write states allowing us to determine what was sent */ @@ -471,6 +473,7 @@ static void unlock(grpc_call *call) { int completing_requests = 0; int start_op = 0; int i; + int cancel_alarm = 0; memset(&op, 0, sizeof(op)); @@ -478,6 +481,9 @@ static void unlock(grpc_call *call) { start_op = op.cancel_with_status != GRPC_STATUS_OK; call->cancel_with_status = GRPC_STATUS_OK; /* reset */ + cancel_alarm = call->cancel_alarm; + call->cancel_alarm = 0; + if (!call->receiving && need_more_data(call)) { op.recv_ops = &call->recv_ops; op.recv_state = &call->recv_state; @@ -512,6 +518,10 @@ static void unlock(grpc_call *call) { gpr_mu_unlock(&call->mu); + if (cancel_alarm) { + grpc_alarm_cancel(&call->alarm); + } + if (start_op) { execute_op(call, &op); } @@ -804,10 +814,7 @@ static void call_on_done_recv(void *pc, int success) { if (call->recv_state == GRPC_STREAM_CLOSED) { GPR_ASSERT(call->read_state <= READ_STATE_STREAM_CLOSED); call->read_state = READ_STATE_STREAM_CLOSED; - if (call->have_alarm) { - grpc_alarm_cancel(&call->alarm); - call->have_alarm = 0; - } + call->cancel_alarm |= call->have_alarm; GRPC_CALL_INTERNAL_UNREF(call, "closed", 0); } finish_read_ops(call); @@ -986,7 +993,7 @@ static void finish_read_ops(grpc_call *call) { switch (call->read_state) { case READ_STATE_STREAM_CLOSED: - if (empty) { + if (empty && !call->have_alarm) { finish_ioreq_op(call, GRPC_IOREQ_RECV_CLOSE, 1); } /* fallthrough */ @@ -1084,10 +1091,7 @@ void grpc_call_destroy(grpc_call *c) { lock(c); GPR_ASSERT(!c->destroy_called); c->destroy_called = 1; - if (c->have_alarm) { - grpc_alarm_cancel(&c->alarm); - c->have_alarm = 0; - } + c->cancel_alarm |= c->have_alarm; cancel = c->read_state != READ_STATE_STREAM_CLOSED; unlock(c); if (cancel) grpc_call_cancel(c); @@ -1167,12 +1171,14 @@ grpc_call *grpc_call_from_top_element(grpc_call_element *elem) { static void call_alarm(void *arg, int success) { grpc_call *call = arg; + lock(call); + call->have_alarm = 0; if (success) { - lock(call); cancel_with_status(call, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"); - unlock(call); } + finish_read_ops(call); + unlock(call); GRPC_CALL_INTERNAL_UNREF(call, "alarm", 1); } |