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
36969385
Commit
36969385
authored
7 years ago
by
Yuchen Zeng
Browse files
Options
Downloads
Patches
Plain Diff
Group the port picking functions
parent
32c0153f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/core/util/port.c
+22
-3
22 additions, 3 deletions
test/core/util/port.c
test/core/util/port.h
+12
-3
12 additions, 3 deletions
test/core/util/port.h
with
34 additions
and
6 deletions
test/core/util/port.c
+
22
−
3
View file @
36969385
...
...
@@ -105,8 +105,27 @@ static void grpc_recycle_unused_port_impl(int port) {
GPR_ASSERT
(
free_chosen_port
(
port
));
}
int
(
*
grpc_pick_unused_port
)(
void
)
=
grpc_pick_unused_port_impl
;
int
(
*
grpc_pick_unused_port_or_die
)(
void
)
=
grpc_pick_unused_port_or_die_impl
;
void
(
*
grpc_recycle_unused_port
)(
int
port
)
=
grpc_recycle_unused_port_impl
;
static
grpc_pick_port_functions
g_pick_port_functions
=
{
grpc_pick_unused_port_impl
,
grpc_pick_unused_port_or_die_impl
,
grpc_recycle_unused_port_impl
};
int
grpc_pick_unused_port
(
void
)
{
return
g_pick_port_functions
.
pick_unused_port_fn
();
}
int
grpc_pick_unused_port_or_die
(
void
)
{
return
g_pick_port_functions
.
pick_unused_port_or_die_fn
();
}
void
grpc_recycle_unused_port
(
int
port
)
{
g_pick_port_functions
.
recycle_unused_port_fn
(
port
);
}
void
grpc_set_pick_port_functions
(
grpc_pick_port_functions
functions
)
{
GPR_ASSERT
(
functions
.
pick_unused_port_fn
!=
NULL
);
GPR_ASSERT
(
functions
.
pick_unused_port_or_die_fn
!=
NULL
);
GPR_ASSERT
(
functions
.
recycle_unused_port_fn
!=
NULL
);
g_pick_port_functions
=
functions
;
}
#endif
/* GRPC_TEST_PICK_PORT */
This diff is collapsed.
Click to expand it.
test/core/util/port.h
+
12
−
3
View file @
36969385
...
...
@@ -23,18 +23,27 @@
extern
"C"
{
#endif
typedef
struct
grpc_pick_port_functions
{
int
(
*
pick_unused_port_fn
)(
void
);
int
(
*
pick_unused_port_or_die_fn
)(
void
);
void
(
*
recycle_unused_port_fn
)(
int
port
);
}
grpc_pick_port_functions
;
/* pick a port number that is currently unused by either tcp or udp. return
0 on failure. */
extern
int
(
*
grpc_pick_unused_port
)
(
void
);
int
grpc_pick_unused_port
(
void
);
/* pick a port number that is currently unused by either tcp or udp. abort
on failure. */
extern
int
(
*
grpc_pick_unused_port_or_die
)
(
void
);
int
grpc_pick_unused_port_or_die
(
void
);
/* Return a port which was previously returned by grpc_pick_unused_port().
* Implementations of grpc_pick_unused_port() backed by a portserver may limit
* the total number of ports available; this lets a binary return its allocated
* ports back to the server if it is going to allocate a large number. */
extern
void
(
*
grpc_recycle_unused_port
)(
int
port
);
void
grpc_recycle_unused_port
(
int
port
);
/** Request the family of pick_port functions in \a functions be used. */
void
grpc_set_pick_port_functions
(
grpc_pick_port_functions
functions
);
#ifdef __cplusplus
}
...
...
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