Progress converting to new error system

pull/6897/head
Craig Tiller 9 years ago
parent d7faf55bee
commit 91472967c7
  1. 44
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  2. 6
      src/core/ext/transport/chttp2/transport/internal.h
  3. 10
      src/core/ext/transport/chttp2/transport/writing.c
  4. 3
      src/core/lib/iomgr/tcp_server_posix.c

@ -143,6 +143,7 @@ static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream *s, grpc_chttp2_stream *s,
void *byte_stream); void *byte_stream);
static void fail_pending_writes(grpc_exec_ctx *exec_ctx, static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global, grpc_chttp2_stream_global *stream_global,
grpc_error *error); grpc_error *error);
@ -750,7 +751,8 @@ static void terminate_writing_with_lock(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global; grpc_chttp2_stream_global *stream_global;
while (grpc_chttp2_list_pop_closed_waiting_for_writing(&t->global, while (grpc_chttp2_list_pop_closed_waiting_for_writing(&t->global,
&stream_global)) { &stream_global)) {
fail_pending_writes(exec_ctx, stream_global, GRPC_ERROR_REF(error)); fail_pending_writes(exec_ctx, &t->global, stream_global,
GRPC_ERROR_REF(error));
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "finish_writes"); GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "finish_writes");
} }
@ -860,9 +862,9 @@ static grpc_closure *add_closure_barrier(grpc_closure *closure) {
return closure; return closure;
} }
void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx, void grpc_chttp2_complete_closure_step(
grpc_chttp2_stream_global *stream_global, grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
grpc_closure **pclosure, grpc_chttp2_stream_global *stream_global, grpc_closure **pclosure,
grpc_error *error) { grpc_error *error) {
grpc_closure *closure = *pclosure; grpc_closure *closure = *pclosure;
if (closure == NULL) { if (closure == NULL) {
@ -874,6 +876,9 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
if (closure->error == GRPC_ERROR_NONE) { if (closure->error == GRPC_ERROR_NONE) {
closure->error = closure->error =
GRPC_ERROR_CREATE("Error in HTTP transport completing operation"); GRPC_ERROR_CREATE("Error in HTTP transport completing operation");
closure->error = grpc_error_set_str(
closure->error, GRPC_ERROR_STR_TARGET_ADDRESS,
TRANSPORT_FROM_GLOBAL(transport_global)->peer_string);
} }
closure->error = grpc_error_add_child(closure->error, error); closure->error = grpc_error_add_child(closure->error, error);
} }
@ -919,6 +924,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
/* use final_data as a barrier until enqueue time; the inital counter is /* use final_data as a barrier until enqueue time; the inital counter is
dropped at the end of this function */ dropped at the end of this function */
on_complete->next_data.scratch = CLOSURE_BARRIER_FIRST_REF_BIT; on_complete->next_data.scratch = CLOSURE_BARRIER_FIRST_REF_BIT;
on_complete->error = GRPC_ERROR_NONE;
if (op->collect_stats != NULL) { if (op->collect_stats != NULL) {
GPR_ASSERT(stream_global->collecting_stats == NULL); GPR_ASSERT(stream_global->collecting_stats == NULL);
@ -957,7 +963,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
} }
} else { } else {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, exec_ctx, transport_global, stream_global,
&stream_global->send_initial_metadata_finished, &stream_global->send_initial_metadata_finished,
GRPC_ERROR_CREATE( GRPC_ERROR_CREATE(
"Attempt to send initial metadata after stream was closed")); "Attempt to send initial metadata after stream was closed"));
@ -970,7 +976,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
stream_global->send_message_finished = add_closure_barrier(on_complete); stream_global->send_message_finished = add_closure_barrier(on_complete);
if (stream_global->write_closed) { if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_message_finished, exec_ctx, transport_global, stream_global,
&stream_global->send_message_finished,
GRPC_ERROR_CREATE("Attempt to send message after stream was closed")); GRPC_ERROR_CREATE("Attempt to send message after stream was closed"));
} else { } else {
stream_global->send_message = op->send_message; stream_global->send_message = op->send_message;
@ -991,7 +998,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
} }
if (stream_global->write_closed) { if (stream_global->write_closed) {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, exec_ctx, transport_global, stream_global,
&stream_global->send_trailing_metadata_finished, &stream_global->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(op->send_trailing_metadata) grpc_metadata_batch_is_empty(op->send_trailing_metadata)
? GRPC_ERROR_NONE ? GRPC_ERROR_NONE
@ -1034,8 +1041,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global); grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
} }
grpc_chttp2_complete_closure_step(exec_ctx, stream_global, &on_complete, grpc_chttp2_complete_closure_step(exec_ctx, transport_global, stream_global,
GRPC_ERROR_NONE); &on_complete, GRPC_ERROR_NONE);
GPR_TIMER_END("perform_stream_op_locked", 0); GPR_TIMER_END("perform_stream_op_locked", 0);
} }
@ -1205,7 +1212,7 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
&stream_global->received_trailing_metadata, &stream_global->received_trailing_metadata,
stream_global->recv_trailing_metadata); stream_global->recv_trailing_metadata);
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, exec_ctx, transport_global, stream_global,
&stream_global->recv_trailing_metadata_finished, GRPC_ERROR_NONE); &stream_global->recv_trailing_metadata_finished, GRPC_ERROR_NONE);
} }
} }
@ -1323,16 +1330,18 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
} }
static void fail_pending_writes(grpc_exec_ctx *exec_ctx, static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global, grpc_chttp2_stream_global *stream_global,
grpc_error *error) { grpc_error *error) {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_initial_metadata_finished, exec_ctx, transport_global, stream_global,
GRPC_ERROR_REF(error)); &stream_global->send_initial_metadata_finished, GRPC_ERROR_REF(error));
grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_trailing_metadata_finished,
GRPC_ERROR_REF(error));
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_message_finished, error); exec_ctx, transport_global, stream_global,
&stream_global->send_trailing_metadata_finished, GRPC_ERROR_REF(error));
grpc_chttp2_complete_closure_step(exec_ctx, transport_global, stream_global,
&stream_global->send_message_finished,
error);
} }
void grpc_chttp2_mark_stream_closed( void grpc_chttp2_mark_stream_closed(
@ -1358,7 +1367,8 @@ void grpc_chttp2_mark_stream_closed(
grpc_chttp2_list_add_closed_waiting_for_writing(transport_global, grpc_chttp2_list_add_closed_waiting_for_writing(transport_global,
stream_global); stream_global);
} else { } else {
fail_pending_writes(exec_ctx, stream_global, GRPC_ERROR_REF(error)); fail_pending_writes(exec_ctx, transport_global, stream_global,
GRPC_ERROR_REF(error));
} }
} }
if (stream_global->read_closed && stream_global->write_closed) { if (stream_global->read_closed && stream_global->write_closed) {

@ -671,9 +671,9 @@ void grpc_chttp2_for_all_streams(
void grpc_chttp2_parsing_become_skip_parser( void grpc_chttp2_parsing_become_skip_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing); grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx, void grpc_chttp2_complete_closure_step(
grpc_chttp2_stream_global *stream_global, grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
grpc_closure **pclosure, grpc_chttp2_stream_global *stream_global, grpc_closure **pclosure,
grpc_error *error); grpc_error *error);
void grpc_chttp2_run_with_global_lock(grpc_exec_ctx *exec_ctx, void grpc_chttp2_run_with_global_lock(grpc_exec_ctx *exec_ctx,

@ -335,21 +335,21 @@ void grpc_chttp2_cleanup_writing(
transport_global, transport_writing, &stream_global, &stream_writing)) { transport_global, transport_writing, &stream_global, &stream_writing)) {
if (stream_writing->sent_initial_metadata) { if (stream_writing->sent_initial_metadata) {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, exec_ctx, transport_global, stream_global,
&stream_global->send_initial_metadata_finished, GRPC_ERROR_NONE); &stream_global->send_initial_metadata_finished, GRPC_ERROR_NONE);
} }
grpc_transport_move_one_way_stats(&stream_writing->stats, grpc_transport_move_one_way_stats(&stream_writing->stats,
&stream_global->stats.outgoing); &stream_global->stats.outgoing);
if (stream_writing->sent_message) { if (stream_writing->sent_message) {
GPR_ASSERT(stream_writing->send_message == NULL); GPR_ASSERT(stream_writing->send_message == NULL);
grpc_chttp2_complete_closure_step(exec_ctx, stream_global, grpc_chttp2_complete_closure_step(
&stream_global->send_message_finished, exec_ctx, transport_global, stream_global,
GRPC_ERROR_NONE); &stream_global->send_message_finished, GRPC_ERROR_NONE);
stream_writing->sent_message = 0; stream_writing->sent_message = 0;
} }
if (stream_writing->sent_trailing_metadata) { if (stream_writing->sent_trailing_metadata) {
grpc_chttp2_complete_closure_step( grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, exec_ctx, transport_global, stream_global,
&stream_global->send_trailing_metadata_finished, GRPC_ERROR_NONE); &stream_global->send_trailing_metadata_finished, GRPC_ERROR_NONE);
} }
if (stream_writing->sent_trailing_metadata) { if (stream_writing->sent_trailing_metadata) {

@ -394,12 +394,13 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
unsigned fd_index, unsigned fd_index,
grpc_tcp_listener **listener) { grpc_tcp_listener **listener) {
grpc_tcp_listener *sp = NULL; grpc_tcp_listener *sp = NULL;
int port; int port = -1;
char *addr_str; char *addr_str;
char *name; char *name;
grpc_error *err = prepare_socket(fd, addr, addr_len, &port); grpc_error *err = prepare_socket(fd, addr, addr_len, &port);
if (err == GRPC_ERROR_NONE) { if (err == GRPC_ERROR_NONE) {
GPR_ASSERT(port > 0);
grpc_sockaddr_to_string(&addr_str, (struct sockaddr *)&addr, 1); grpc_sockaddr_to_string(&addr_str, (struct sockaddr *)&addr, 1);
gpr_asprintf(&name, "tcp-server-listener:%s", addr_str); gpr_asprintf(&name, "tcp-server-listener:%s", addr_str);
gpr_mu_lock(&s->mu); gpr_mu_lock(&s->mu);

Loading…
Cancel
Save