Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into cleaner-posix2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Mar 30, 2016
2 parents 503b8f6 + 90da737 commit ef63762
Show file tree
Hide file tree
Showing 44 changed files with 1,959 additions and 72 deletions.
102 changes: 102 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,9 @@ httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
init_test: $(BINDIR)/$(CONFIG)/init_test
internal_api_canary_iomgr_test: $(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test
internal_api_canary_support_test: $(BINDIR)/$(CONFIG)/internal_api_canary_support_test
internal_api_canary_transport_test: $(BINDIR)/$(CONFIG)/internal_api_canary_transport_test
invalid_call_argument_test: $(BINDIR)/$(CONFIG)/invalid_call_argument_test
json_fuzzer_test: $(BINDIR)/$(CONFIG)/json_fuzzer_test
json_rewrite: $(BINDIR)/$(CONFIG)/json_rewrite
Expand Down Expand Up @@ -1248,6 +1251,9 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/httpcli_test \
$(BINDIR)/$(CONFIG)/httpscli_test \
$(BINDIR)/$(CONFIG)/init_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_support_test \
$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test \
$(BINDIR)/$(CONFIG)/invalid_call_argument_test \
$(BINDIR)/$(CONFIG)/json_rewrite \
$(BINDIR)/$(CONFIG)/json_rewrite_test \
Expand Down Expand Up @@ -8068,6 +8074,102 @@ endif
endif


INTERNAL_API_CANARY_IOMGR_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \

INTERNAL_API_CANARY_IOMGR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_IOMGR_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test: $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_iomgr_test

endif

$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_internal_api_canary_iomgr_test: $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_IOMGR_TEST_OBJS:.o=.dep)
endif
endif


INTERNAL_API_CANARY_SUPPORT_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \

INTERNAL_API_CANARY_SUPPORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_SUPPORT_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/internal_api_canary_support_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/internal_api_canary_support_test: $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_support_test

endif

$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_internal_api_canary_support_test: $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_SUPPORT_TEST_OBJS:.o=.dep)
endif
endif


INTERNAL_API_CANARY_TRANSPORT_TEST_SRC = \
test/core/internal_api_canaries/iomgr.c \

INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INTERNAL_API_CANARY_TRANSPORT_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/internal_api_canary_transport_test: $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/internal_api_canary_transport_test

endif

$(OBJDIR)/$(CONFIG)/test/core/internal_api_canaries/iomgr.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_internal_api_canary_transport_test: $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INTERNAL_API_CANARY_TRANSPORT_TEST_OBJS:.o=.dep)
endif
endif


INVALID_CALL_ARGUMENT_TEST_SRC = \
test/core/end2end/invalid_call_argument_test.c \

Expand Down
2 changes: 2 additions & 0 deletions PYTHON-MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ recursive-include src/python/grpcio/grpc *.c *.h *.py *.pyx *.pxd *.pxi *.python
recursive-exclude src/python/grpcio/grpc/_cython *.so *.pyd
graft src/python/grpcio/tests
graft src/core
graft src/boringssl
graft include/grpc
graft third_party/boringssl
graft third_party/nanopb
graft third_party/zlib
include src/python/grpcio/commands.py
include src/python/grpcio/grpc_version.py
Expand Down
33 changes: 33 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,39 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_iomgr_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_support_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: internal_api_canary_transport_test
build: test
run: false
language: c
src:
- test/core/internal_api_canaries/iomgr.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: invalid_call_argument_test
build: test
language: c
Expand Down
57 changes: 41 additions & 16 deletions src/core/ext/transport/chttp2/transport/chttp2_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,23 +758,35 @@ static void maybe_start_some_streams(
}
}

#define CLOSURE_BARRIER_STATS_BIT (1 << 0)
#define CLOSURE_BARRIER_FAILURE_BIT (1 << 1)
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)

static grpc_closure *add_closure_barrier(grpc_closure *closure) {
closure->final_data += 2;
closure->final_data += CLOSURE_BARRIER_FIRST_REF_BIT;
return closure;
}

void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global,
grpc_closure **pclosure, int success) {
grpc_closure *closure = *pclosure;
if (closure == NULL) {
return;
}
closure->final_data -= 2;
closure->final_data -= CLOSURE_BARRIER_FIRST_REF_BIT;
if (!success) {
closure->final_data |= 1;
closure->final_data |= CLOSURE_BARRIER_FAILURE_BIT;
}
if (closure->final_data < 2) {
grpc_exec_ctx_enqueue(exec_ctx, closure, closure->final_data == 0, NULL);
if (closure->final_data < CLOSURE_BARRIER_FIRST_REF_BIT) {
if (closure->final_data & CLOSURE_BARRIER_STATS_BIT) {
grpc_transport_move_stats(&stream_global->stats,
stream_global->collecting_stats);
stream_global->collecting_stats = NULL;
}
grpc_exec_ctx_enqueue(
exec_ctx, closure,
(closure->final_data & CLOSURE_BARRIER_FAILURE_BIT) == 0, NULL);
}
*pclosure = NULL;
}
Expand Down Expand Up @@ -807,7 +819,13 @@ static void perform_stream_op_locked(
}
/* use final_data as a barrier until enqueue time; the inital counter is
dropped at the end of this function */
on_complete->final_data = 2;
on_complete->final_data = CLOSURE_BARRIER_FIRST_REF_BIT;

if (op->collect_stats != NULL) {
GPR_ASSERT(stream_global->collecting_stats == NULL);
stream_global->collecting_stats = op->collect_stats;
on_complete->final_data |= CLOSURE_BARRIER_STATS_BIT;
}

if (op->cancel_with_status != GRPC_STATUS_OK) {
cancel_from_api(exec_ctx, transport_global, stream_global,
Expand Down Expand Up @@ -840,7 +858,8 @@ static void perform_stream_op_locked(
}
} else {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 0);
exec_ctx, stream_global,
&stream_global->send_initial_metadata_finished, 0);
}
}

Expand All @@ -850,7 +869,7 @@ static void perform_stream_op_locked(
stream_global->send_message_finished = add_closure_barrier(on_complete);
if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_message_finished, 0);
exec_ctx, stream_global, &stream_global->send_message_finished, 0);
} else {
stream_global->send_message = op->send_message;
if (stream_global->id != 0) {
Expand All @@ -870,7 +889,8 @@ static void perform_stream_op_locked(
}
if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_trailing_metadata_finished,
exec_ctx, stream_global,
&stream_global->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(op->send_trailing_metadata));
} else if (stream_global->id != 0) {
/* TODO(ctiller): check if there's flow control for any outstanding
Expand Down Expand Up @@ -909,7 +929,7 @@ static void perform_stream_op_locked(
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
}

grpc_chttp2_complete_closure_step(exec_ctx, &on_complete, 1);
grpc_chttp2_complete_closure_step(exec_ctx, stream_global, &on_complete, 1);

GPR_TIMER_END("perform_stream_op_locked", 0);
}
Expand Down Expand Up @@ -1080,7 +1100,8 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
&stream_global->received_trailing_metadata,
stream_global->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->recv_trailing_metadata_finished, 1);
exec_ctx, stream_global,
&stream_global->recv_trailing_metadata_finished, 1);
}
}
}
Expand Down Expand Up @@ -1131,7 +1152,8 @@ static void cancel_from_api(grpc_exec_ctx *exec_ctx,
&transport_global->qbuf,
grpc_chttp2_rst_stream_create(
stream_global->id,
(uint32_t)grpc_chttp2_grpc_status_to_http2_error(status)));
(uint32_t)grpc_chttp2_grpc_status_to_http2_error(status),
&stream_global->stats.outgoing));
}
grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status,
NULL);
Expand Down Expand Up @@ -1179,10 +1201,12 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global) {
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_initial_metadata_finished, 0);
exec_ctx, stream_global, &stream_global->send_initial_metadata_finished,
0);
grpc_chttp2_complete_closure_step(
exec_ctx, &stream_global->send_trailing_metadata_finished, 0);
grpc_chttp2_complete_closure_step(exec_ctx,
exec_ctx, stream_global, &stream_global->send_trailing_metadata_finished,
0);
grpc_chttp2_complete_closure_step(exec_ctx, stream_global,
&stream_global->send_message_finished, 0);
}

Expand Down Expand Up @@ -1319,7 +1343,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx,

gpr_slice_buffer_add(
&transport_global->qbuf,
grpc_chttp2_rst_stream_create(stream_global->id, GRPC_CHTTP2_NO_ERROR));
grpc_chttp2_rst_stream_create(stream_global->id, GRPC_CHTTP2_NO_ERROR,
&stream_global->stats.outgoing));

if (optional_message) {
gpr_slice_ref(*optional_message);
Expand Down
Loading

0 comments on commit ef63762

Please sign in to comment.