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
513aa6cb
Commit
513aa6cb
authored
8 years ago
by
Yuchen Zeng
Browse files
Options
Downloads
Patches
Plain Diff
Use _locked functions in dns_ares_resolver_vtable
parent
c75bbf28
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
+21
-72
21 additions, 72 deletions
src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
+0
-1
0 additions, 1 deletion
src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
with
21 additions
and
73 deletions
src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
+
21
−
72
View file @
513aa6cb
...
...
@@ -71,8 +71,6 @@ typedef struct {
grpc_pollset_set
*
interested_parties
;
/** Closures used by the combiner */
grpc_closure
dns_ares_shutdown_locked
;
grpc_closure
dns_ares_channel_saw_error_locked
;
grpc_closure
dns_ares_on_retry_timer_locked
;
grpc_closure
dns_ares_on_resolved_locked
;
...
...
@@ -107,21 +105,20 @@ static void dns_ares_start_resolving_locked(grpc_exec_ctx *exec_ctx,
static
void
dns_ares_maybe_finish_next_locked
(
grpc_exec_ctx
*
exec_ctx
,
ares_dns_resolver
*
r
);
static
void
dns_ares_shutdown
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
);
static
void
dns_ares_channel_saw_error
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
);
static
void
dns_ares_next
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
,
grpc_channel_args
**
target_result
,
grpc_closure
*
on_complete
);
static
void
dns_ares_shutdown
_locked
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
);
static
void
dns_ares_channel_saw_error
_locked
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
);
static
void
dns_ares_next
_locked
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
r
,
grpc_channel_args
**
target_result
,
grpc_closure
*
on_complete
);
static
const
grpc_resolver_vtable
dns_ares_resolver_vtable
=
{
dns_ares_destroy
,
dns_ares_shutdown
,
dns_ares_channel_saw_error
,
dns_ares_
next
};
dns_ares_destroy
,
dns_ares_shutdown
_locked
,
dns_ares_
channel_saw_error_locked
,
dns_ares_next_locked
};
static
void
dns_ares_shutdown_locked
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
ares_dns_resolver
*
r
=
arg
;
GPR_ASSERT
(
error
==
GRPC_ERROR_NONE
);
static
void
dns_ares_shutdown_locked
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
resolver
)
{
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
if
(
r
->
have_retry_timer
)
{
grpc_timer_cancel
(
exec_ctx
,
&
r
->
retry_timer
);
}
...
...
@@ -131,33 +128,15 @@ static void dns_ares_shutdown_locked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_ERROR_CREATE
(
"Resolver Shutdown"
));
r
->
next_completion
=
NULL
;
}
GRPC_RESOLVER_UNREF
(
exec_ctx
,
&
r
->
base
,
"dns-ares-shutdown"
);
}
static
void
dns_ares_shutdown
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
resolver
)
{
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
GRPC_RESOLVER_REF
(
&
r
->
base
,
"dns-ares-shutdown"
);
grpc_closure_sched
(
exec_ctx
,
&
r
->
dns_ares_shutdown_locked
,
GRPC_ERROR_NONE
);
}
static
void
dns_ares_channel_saw_error_locked
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
GPR_ASSERT
(
error
==
GRPC_ERROR_NONE
);
ares_dns_resolver
*
r
=
arg
;
grpc_resolver
*
resolver
)
{
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
if
(
!
r
->
resolving
)
{
gpr_backoff_reset
(
&
r
->
backoff_state
);
dns_ares_start_resolving_locked
(
exec_ctx
,
r
);
}
GRPC_RESOLVER_UNREF
(
exec_ctx
,
&
r
->
base
,
"ares-channel-saw-error"
);
}
static
void
dns_ares_channel_saw_error
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
resolver
)
{
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
GRPC_RESOLVER_REF
(
&
r
->
base
,
"ares-channel-saw-error"
);
grpc_closure_sched
(
exec_ctx
,
&
r
->
dns_ares_channel_saw_error_locked
,
GRPC_ERROR_NONE
);
}
static
void
dns_ares_on_retry_timer_locked
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
...
...
@@ -218,46 +197,21 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_RESOLVER_UNREF
(
exec_ctx
,
&
r
->
base
,
"dns-resolving"
);
}
typedef
struct
dns_ares_next_locked_args
{
grpc_resolver
*
resolver
;
grpc_channel_args
**
target_result
;
grpc_closure
*
on_complete
;
}
dns_ares_next_locked_args
;
static
void
dns_ares_next_locked
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
GPR_ASSERT
(
error
==
GRPC_ERROR_NONE
);
dns_ares_next_locked_args
*
args
=
arg
;
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
args
->
resolver
;
static
void
dns_ares_next_locked
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
resolver
,
grpc_channel_args
**
target_result
,
grpc_closure
*
on_complete
)
{
gpr_log
(
GPR_DEBUG
,
"dns_ares_next is called."
);
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
GPR_ASSERT
(
!
r
->
next_completion
);
r
->
next_completion
=
args
->
on_complete
;
r
->
target_result
=
args
->
target_result
;
gpr_free
(
arg
);
r
->
next_completion
=
on_complete
;
r
->
target_result
=
target_result
;
if
(
r
->
resolved_version
==
0
&&
!
r
->
resolving
)
{
gpr_backoff_reset
(
&
r
->
backoff_state
);
dns_ares_start_resolving_locked
(
exec_ctx
,
r
);
}
else
{
dns_ares_maybe_finish_next_locked
(
exec_ctx
,
r
);
}
GRPC_RESOLVER_UNREF
(
exec_ctx
,
&
r
->
base
,
"ares-next"
);
}
static
void
dns_ares_next
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resolver
*
resolver
,
grpc_channel_args
**
target_result
,
grpc_closure
*
on_complete
)
{
ares_dns_resolver
*
r
=
(
ares_dns_resolver
*
)
resolver
;
dns_ares_next_locked_args
*
args
=
gpr_zalloc
(
sizeof
(
dns_ares_next_locked_args
));
args
->
target_result
=
target_result
;
args
->
on_complete
=
on_complete
;
args
->
resolver
=
resolver
;
GRPC_RESOLVER_REF
(
resolver
,
"ares-next"
);
grpc_closure_sched
(
exec_ctx
,
grpc_closure_create
(
dns_ares_next_locked
,
args
,
grpc_combiner_scheduler
(
r
->
base
.
combiner
,
false
)),
GRPC_ERROR_NONE
);
}
static
void
dns_ares_start_resolving_locked
(
grpc_exec_ctx
*
exec_ctx
,
...
...
@@ -323,11 +277,6 @@ static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
GRPC_DNS_RECONNECT_JITTER
,
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS
*
1000
,
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS
*
1000
);
grpc_closure_init
(
&
r
->
dns_ares_shutdown_locked
,
dns_ares_shutdown_locked
,
r
,
grpc_combiner_scheduler
(
r
->
base
.
combiner
,
false
));
grpc_closure_init
(
&
r
->
dns_ares_channel_saw_error_locked
,
dns_ares_channel_saw_error_locked
,
r
,
grpc_combiner_scheduler
(
r
->
base
.
combiner
,
false
));
grpc_closure_init
(
&
r
->
dns_ares_on_retry_timer_locked
,
dns_ares_on_retry_timer_locked
,
r
,
grpc_combiner_scheduler
(
r
->
base
.
combiner
,
false
));
...
...
@@ -370,7 +319,7 @@ static grpc_resolver_factory *dns_ares_resolver_factory_create() {
void
grpc_resolver_dns_ares_init
(
void
)
{
char
*
resolver
=
gpr_getenv
(
"GRPC_DNS_RESOLVER"
);
/* TODO(zyc): Turn on c-ares based resolver by default after the address
sorter
is
added. */
sorter
and the CNAME support are
added. */
if
(
resolver
!=
NULL
&&
gpr_stricmp
(
resolver
,
"ares"
)
==
0
)
{
grpc_error
*
error
=
grpc_ares_init
();
if
(
error
!=
GRPC_ERROR_NONE
)
{
...
...
This diff is collapsed.
Click to expand it.
src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
+
0
−
1
View file @
513aa6cb
...
...
@@ -296,7 +296,6 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx *exec_ctx,
while
(
ev_driver
->
fds
!=
NULL
)
{
fd_node
*
cur
=
ev_driver
->
fds
;
ev_driver
->
fds
=
ev_driver
->
fds
->
next
;
// grpc_fd_shutdown(exec_ctx, cur->grpc_fd);
fd_node_destroy
(
exec_ctx
,
cur
);
}
ev_driver
->
fds
=
new_list
;
...
...
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