|
|
@ -103,7 +103,8 @@ struct grpc_subchannel_call { |
|
|
|
#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1)) |
|
|
|
#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1)) |
|
|
|
#define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)((con) + 1)) |
|
|
|
#define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)((con) + 1)) |
|
|
|
|
|
|
|
|
|
|
|
static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op); |
|
|
|
static grpc_subchannel_call *create_call(connection *con, |
|
|
|
|
|
|
|
grpc_transport_stream_op *initial_op); |
|
|
|
static void connectivity_state_changed_locked(grpc_subchannel *c); |
|
|
|
static void connectivity_state_changed_locked(grpc_subchannel *c); |
|
|
|
static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); |
|
|
|
static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); |
|
|
|
static gpr_timespec compute_connect_deadline(grpc_subchannel *c); |
|
|
|
static gpr_timespec compute_connect_deadline(grpc_subchannel *c); |
|
|
@ -112,7 +113,8 @@ static void subchannel_connected(void *subchannel, int iomgr_success); |
|
|
|
static void subchannel_ref_locked(grpc_subchannel *c); |
|
|
|
static void subchannel_ref_locked(grpc_subchannel *c); |
|
|
|
static int subchannel_unref_locked(grpc_subchannel *c) GRPC_MUST_USE_RESULT; |
|
|
|
static int subchannel_unref_locked(grpc_subchannel *c) GRPC_MUST_USE_RESULT; |
|
|
|
static void connection_ref_locked(connection *c); |
|
|
|
static void connection_ref_locked(connection *c); |
|
|
|
static grpc_subchannel *connection_unref_locked(connection *c) GRPC_MUST_USE_RESULT; |
|
|
|
static grpc_subchannel *connection_unref_locked(connection *c) |
|
|
|
|
|
|
|
GRPC_MUST_USE_RESULT; |
|
|
|
static void subchannel_destroy(grpc_subchannel *c); |
|
|
|
static void subchannel_destroy(grpc_subchannel *c); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -141,14 +143,11 @@ static grpc_subchannel *connection_unref_locked(connection *c) { |
|
|
|
return destroy; |
|
|
|
return destroy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* grpc_subchannel implementation |
|
|
|
* grpc_subchannel implementation |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
static void subchannel_ref_locked(grpc_subchannel *c) {
|
|
|
|
static void subchannel_ref_locked(grpc_subchannel *c) { ++c->refs; } |
|
|
|
++c->refs; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int subchannel_unref_locked(grpc_subchannel *c) { |
|
|
|
static int subchannel_unref_locked(grpc_subchannel *c) { |
|
|
|
return --c->refs == 0; |
|
|
|
return --c->refs == 0; |
|
|
@ -225,7 +224,8 @@ static void start_connect(grpc_subchannel *c) { |
|
|
|
args.channel_args = c->args; |
|
|
|
args.channel_args = c->args; |
|
|
|
args.metadata_context = c->mdctx; |
|
|
|
args.metadata_context = c->mdctx; |
|
|
|
|
|
|
|
|
|
|
|
grpc_connector_connect(c->connector, &args, &c->connecting_result, &c->connected); |
|
|
|
grpc_connector_connect(c->connector, &args, &c->connecting_result, |
|
|
|
|
|
|
|
&c->connected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void grpc_subchannel_create_call(grpc_subchannel *c, |
|
|
|
void grpc_subchannel_create_call(grpc_subchannel *c, |
|
|
@ -275,11 +275,13 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, |
|
|
|
grpc_iomgr_closure *notify) { |
|
|
|
grpc_iomgr_closure *notify) { |
|
|
|
int do_connect = 0; |
|
|
|
int do_connect = 0; |
|
|
|
gpr_mu_lock(&c->mu); |
|
|
|
gpr_mu_lock(&c->mu); |
|
|
|
if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, notify)) { |
|
|
|
if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, |
|
|
|
|
|
|
|
notify)) { |
|
|
|
do_connect = 1; |
|
|
|
do_connect = 1; |
|
|
|
c->connecting = 1; |
|
|
|
c->connecting = 1; |
|
|
|
subchannel_ref_locked(c); |
|
|
|
subchannel_ref_locked(c); |
|
|
|
grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); |
|
|
|
grpc_connectivity_state_set(&c->state_tracker, |
|
|
|
|
|
|
|
compute_connectivity_locked(c)); |
|
|
|
} |
|
|
|
} |
|
|
|
gpr_mu_unlock(&c->mu); |
|
|
|
gpr_mu_unlock(&c->mu); |
|
|
|
if (do_connect) { |
|
|
|
if (do_connect) { |
|
|
@ -287,7 +289,8 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { |
|
|
|
void grpc_subchannel_process_transport_op(grpc_subchannel *c, |
|
|
|
|
|
|
|
grpc_transport_op *op) { |
|
|
|
abort(); |
|
|
|
abort(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -303,7 +306,8 @@ static void publish_transport(grpc_subchannel *c) { |
|
|
|
num_filters = c->num_filters + c->connecting_result.num_filters + 1; |
|
|
|
num_filters = c->num_filters + c->connecting_result.num_filters + 1; |
|
|
|
filters = gpr_malloc(sizeof(*filters) * num_filters); |
|
|
|
filters = gpr_malloc(sizeof(*filters) * num_filters); |
|
|
|
memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); |
|
|
|
memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); |
|
|
|
memcpy(filters + c->num_filters, c->connecting_result.filters, sizeof(*filters) * c->connecting_result.num_filters); |
|
|
|
memcpy(filters + c->num_filters, c->connecting_result.filters, |
|
|
|
|
|
|
|
sizeof(*filters) * c->connecting_result.num_filters); |
|
|
|
filters[num_filters - 1] = &grpc_connected_channel_filter; |
|
|
|
filters[num_filters - 1] = &grpc_connected_channel_filter; |
|
|
|
|
|
|
|
|
|
|
|
channel_stack_size = grpc_channel_stack_size(filters, num_filters); |
|
|
|
channel_stack_size = grpc_channel_stack_size(filters, num_filters); |
|
|
@ -372,9 +376,7 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { |
|
|
|
* grpc_subchannel_call implementation |
|
|
|
* grpc_subchannel_call implementation |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
void grpc_subchannel_call_ref(grpc_subchannel_call *c) {
|
|
|
|
void grpc_subchannel_call_ref(grpc_subchannel_call *c) { gpr_ref(&c->refs); } |
|
|
|
gpr_ref(&c->refs); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void grpc_subchannel_call_unref(grpc_subchannel_call *c) { |
|
|
|
void grpc_subchannel_call_unref(grpc_subchannel_call *c) { |
|
|
|
if (gpr_unref(&c->refs)) { |
|
|
|
if (gpr_unref(&c->refs)) { |
|
|
@ -398,9 +400,11 @@ void grpc_subchannel_call_process_op(grpc_subchannel_call *call, |
|
|
|
top_elem->filter->start_transport_stream_op(top_elem, op); |
|
|
|
top_elem->filter->start_transport_stream_op(top_elem, op); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op) { |
|
|
|
grpc_subchannel_call *create_call(connection *con, |
|
|
|
|
|
|
|
grpc_transport_stream_op *initial_op) { |
|
|
|
grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); |
|
|
|
grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); |
|
|
|
grpc_subchannel_call *call = gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); |
|
|
|
grpc_subchannel_call *call = |
|
|
|
|
|
|
|
gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); |
|
|
|
grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call); |
|
|
|
grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call); |
|
|
|
call->connection = con; |
|
|
|
call->connection = con; |
|
|
|
gpr_ref_init(&call->refs, 1); |
|
|
|
gpr_ref_init(&call->refs, 1); |
|
|
|