diff options
Diffstat (limited to 'src/core/transport/chttp2_transport.c')
-rw-r--r-- | src/core/transport/chttp2_transport.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 80b1027a03..f53c5fa49b 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -68,10 +68,10 @@ int grpc_http_trace = 0; typedef struct transport transport; typedef struct stream stream; -#define IF_TRACING(stmt) \ - if (!(grpc_http_trace)) \ - ; \ - else \ +#define IF_TRACING(stmt) \ + if (!(grpc_http_trace)) \ + ; \ + else \ stmt /* streams are kept in various linked lists depending on what things need to @@ -583,7 +583,7 @@ static int init_stream(grpc_transport *gt, grpc_stream *gs, lock(t); s->id = 0; } else { - s->id = (gpr_uint32)(gpr_uintptr) server_data; + s->id = (gpr_uint32)(gpr_uintptr)server_data; t->incoming_stream = s; grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); } @@ -708,7 +708,8 @@ static void stream_list_add_tail(transport *t, stream *s, stream_list_id id) { } static void stream_list_join(transport *t, stream *s, stream_list_id id) { - if (id == PENDING_CALLBACKS) GPR_ASSERT(t->cb != NULL || t->error_state == ERROR_STATE_NONE); + if (id == PENDING_CALLBACKS) + GPR_ASSERT(t->cb != NULL || t->error_state == ERROR_STATE_NONE); if (s->included[id]) { return; } @@ -770,7 +771,7 @@ static void unlock(transport *t) { if (t->error_state == ERROR_STATE_SEEN && !t->writing) { call_closed = 1; t->calling_back = 1; - t->cb = NULL; /* no more callbacks */ + t->cb = NULL; /* no more callbacks */ t->error_state = ERROR_STATE_NOTIFIED; } if (t->num_pending_goaways) { @@ -792,8 +793,7 @@ static void unlock(transport *t) { /* perform some callbacks if necessary */ for (i = 0; i < num_goaways; i++) { - cb->goaway(t->cb_user_data, &t->base, goaways[i].status, - goaways[i].debug); + cb->goaway(t->cb_user_data, &t->base, goaways[i].status, goaways[i].debug); } if (perform_callbacks) { @@ -1069,8 +1069,11 @@ static void finalize_cancellations(transport *t) { static void add_incoming_metadata(transport *t, stream *s, grpc_mdelem *elem) { if (s->incoming_metadata_capacity == s->incoming_metadata_count) { - s->incoming_metadata_capacity = GPR_MAX(8, 2 * s->incoming_metadata_capacity); - s->incoming_metadata = gpr_realloc(s->incoming_metadata, sizeof(*s->incoming_metadata) * s->incoming_metadata_capacity); + s->incoming_metadata_capacity = + GPR_MAX(8, 2 * s->incoming_metadata_capacity); + s->incoming_metadata = + gpr_realloc(s->incoming_metadata, sizeof(*s->incoming_metadata) * + s->incoming_metadata_capacity); } s->incoming_metadata[s->incoming_metadata_count++].md = elem; } @@ -1094,10 +1097,14 @@ static void cancel_stream_inner(transport *t, stream *s, gpr_uint32 id, stream_list_join(t, s, CANCELLED); gpr_ltoa(local_status, buffer); - add_incoming_metadata(t, s, grpc_mdelem_from_strings(t->metadata_context, "grpc-status", buffer)); + add_incoming_metadata( + t, s, + grpc_mdelem_from_strings(t->metadata_context, "grpc-status", buffer)); switch (local_status) { case GRPC_STATUS_CANCELLED: - add_incoming_metadata(t, s, grpc_mdelem_from_strings(t->metadata_context, "grpc-message", "Cancelled")); + add_incoming_metadata( + t, s, grpc_mdelem_from_strings(t->metadata_context, + "grpc-message", "Cancelled")); break; default: break; @@ -1325,7 +1332,7 @@ static int init_header_frame_parser(transport *t, int is_continuation) { t->incoming_stream = NULL; /* if stream is accepted, we set incoming_stream in init_stream */ t->cb->accept_stream(t->cb_user_data, &t->base, - (void *)(gpr_uintptr) t->incoming_stream_id); + (void *)(gpr_uintptr)t->incoming_stream_id); s = t->incoming_stream; if (!s) { gpr_log(GPR_ERROR, "stream not accepted"); @@ -1456,9 +1463,7 @@ static int is_window_update_legal(gpr_uint32 window_update, gpr_uint32 window) { return window_update < MAX_WINDOW - window; } -static void free_md(void *p, grpc_op_error result) { - gpr_free(p); -} +static void free_md(void *p, grpc_op_error result) { gpr_free(p); } static void add_metadata_batch(transport *t, stream *s) { grpc_metadata_batch b; @@ -1477,7 +1482,8 @@ static void add_metadata_batch(transport *t, stream *s) { s->incoming_metadata[s->incoming_metadata_count - 1].next = NULL; grpc_sopb_add_metadata(&s->parser.incoming_sopb, b); - grpc_sopb_add_flow_ctl_cb(&s->parser.incoming_sopb, free_md, s->incoming_metadata); + grpc_sopb_add_flow_ctl_cb(&s->parser.incoming_sopb, free_md, + s->incoming_metadata); /* reset */ s->incoming_deadline = gpr_inf_future; @@ -1619,8 +1625,8 @@ static int process_read(transport *t, gpr_slice slice) { "Connect string mismatch: expected '%c' (%d) got '%c' (%d) " "at byte %d", CLIENT_CONNECT_STRING[t->deframe_state], - (int)(gpr_uint8) CLIENT_CONNECT_STRING[t->deframe_state], - *cur, (int)*cur, t->deframe_state); + (int)(gpr_uint8)CLIENT_CONNECT_STRING[t->deframe_state], *cur, + (int)*cur, t->deframe_state); drop_connection(t); return 0; } @@ -1867,9 +1873,9 @@ static void add_to_pollset(grpc_transport *gt, grpc_pollset *pollset) { */ static const grpc_transport_vtable vtable = { - sizeof(stream), init_stream, send_batch, set_allow_window_updates, - add_to_pollset, destroy_stream, abort_stream, goaway, - close_transport, send_ping, destroy_transport}; + sizeof(stream), init_stream, send_batch, set_allow_window_updates, + add_to_pollset, destroy_stream, abort_stream, goaway, close_transport, + send_ping, destroy_transport}; void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, void *arg, |