aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/util/port.h
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-08-02 16:40:24 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2017-08-02 16:40:24 -0700
commit36969385e50ac6340129b85df11de72b23ec05e2 (patch)
tree6a30ba8aed95d9605eb556bd4434d60b58cb6c20 /test/core/util/port.h
parent32c0153f8181feb89e0abf2ef47c02fb63f70063 (diff)
Group the port picking functions
Diffstat (limited to 'test/core/util/port.h')
-rw-r--r--test/core/util/port.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/core/util/port.h b/test/core/util/port.h
index 0e15f397a5..602099dea6 100644
--- a/test/core/util/port.h
+++ b/test/core/util/port.h
@@ -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
}