Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
b09d84d7
Commit
b09d84d7
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Discard unnecessary subchannels when they're no longer required
parent
3ff551bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/client_config/lb_policies/pick_first.c
+35
-0
35 additions, 0 deletions
src/core/client_config/lb_policies/pick_first.c
with
35 additions
and
0 deletions
src/core/client_config/lb_policies/pick_first.c
+
35
−
0
View file @
b09d84d7
...
@@ -172,6 +172,37 @@ void pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
...
@@ -172,6 +172,37 @@ void pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
}
}
}
}
static
void
destroy_subchannels
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
int
iomgr_success
)
{
pick_first_lb_policy
*
p
=
arg
;
size_t
i
;
grpc_transport_op
op
;
size_t
num_subchannels
=
p
->
num_subchannels
;
grpc_subchannel
**
subchannels
;
grpc_subchannel
*
exclude_subchannel
;
gpr_mu_lock
(
&
p
->
mu
);
subchannels
=
p
->
subchannels
;
exclude_subchannel
=
p
->
selected
;
p
->
num_subchannels
=
0
;
p
->
subchannels
=
NULL
;
gpr_mu_unlock
(
&
p
->
mu
);
GRPC_LB_POLICY_UNREF
(
exec_ctx
,
&
p
->
base
,
"destroy_subchannels"
);
for
(
i
=
0
;
i
<
num_subchannels
;
i
++
)
{
if
(
subchannels
[
i
]
==
exclude_subchannel
)
{
exclude_subchannel
=
NULL
;
continue
;
}
memset
(
&
op
,
0
,
sizeof
(
op
));
op
.
disconnect
=
1
;
grpc_subchannel_process_transport_op
(
exec_ctx
,
subchannels
[
i
],
&
op
);
GRPC_SUBCHANNEL_UNREF
(
exec_ctx
,
subchannels
[
i
],
"pick_first"
);
}
gpr_free
(
subchannels
);
}
static
void
pf_connectivity_changed
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
static
void
pf_connectivity_changed
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
int
iomgr_success
)
{
int
iomgr_success
)
{
pick_first_lb_policy
*
p
=
arg
;
pick_first_lb_policy
*
p
=
arg
;
...
@@ -200,6 +231,10 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
...
@@ -200,6 +231,10 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_connectivity_state_set
(
exec_ctx
,
&
p
->
state_tracker
,
grpc_connectivity_state_set
(
exec_ctx
,
&
p
->
state_tracker
,
GRPC_CHANNEL_READY
,
"connecting_ready"
);
GRPC_CHANNEL_READY
,
"connecting_ready"
);
p
->
selected
=
p
->
subchannels
[
p
->
checking_subchannel
];
p
->
selected
=
p
->
subchannels
[
p
->
checking_subchannel
];
/* drop the pick list: we are connected now */
GRPC_LB_POLICY_REF
(
&
p
->
base
,
"destroy_subchannels"
);
grpc_exec_ctx_enqueue
(
exec_ctx
,
grpc_closure_create
(
destroy_subchannels
,
p
),
1
);
/* update any calls that were waiting for a pick */
while
((
pp
=
p
->
pending_picks
))
{
while
((
pp
=
p
->
pending_picks
))
{
p
->
pending_picks
=
pp
->
next
;
p
->
pending_picks
=
pp
->
next
;
*
pp
->
target
=
p
->
selected
;
*
pp
->
target
=
p
->
selected
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment