aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-02-13 14:40:39 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-02-15 21:30:13 -0800
commit58a62755fc6546a117b7b8f3a0a344f85b2ea5f9 (patch)
tree294e8432672a2a8b3b2bd1bab7d24e75e1a6d4b6 /test
parentb0d71823a0f031ad1c04be30f22653177139da0b (diff)
Remove support for detached threads. All threads must be joined.
Diffstat (limited to 'test')
-rw-r--r--test/core/bad_client/bad_client.cc5
-rw-r--r--test/core/end2end/bad_server_response_test.cc11
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc5
-rw-r--r--test/core/end2end/fixtures/proxy.cc4
-rw-r--r--test/core/end2end/tests/connectivity.cc5
-rw-r--r--test/core/gpr/arena_test.cc5
-rw-r--r--test/core/gpr/cpu_test.cc15
-rw-r--r--test/core/gpr/mpscq_test.cc17
-rw-r--r--test/core/gpr/spinlock_test.cc5
-rw-r--r--test/core/gpr/sync_test.cc17
-rw-r--r--test/core/gpr/thd_test.cc45
-rw-r--r--test/core/gpr/tls_test.cc5
-rw-r--r--test/core/handshake/client_ssl.cc5
-rw-r--r--test/core/handshake/server_ssl_common.cc5
-rw-r--r--test/core/iomgr/combiner_test.cc6
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc4
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc5
-rw-r--r--test/core/iomgr/wakeup_fd_cv_test.cc13
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc4
-rw-r--r--test/core/surface/completion_queue_threading_test.cc21
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc20
-rw-r--r--test/core/surface/sequential_connectivity_test.cc4
22 files changed, 99 insertions, 127 deletions
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index 6055ccbf4b..9abc1c40d9 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -220,11 +220,11 @@ void grpc_run_bad_client_test(
/* Check a ground truth */
GPR_ASSERT(grpc_server_has_open_connections(a.server));
- gpr_thd_id id;
+ gpr_thd_id server_validator_id;
gpr_event_init(&a.done_thd);
a.validator = server_validator;
/* Start validator */
- gpr_thd_new(&id, "grpc_bad_client", thd_func, &a, nullptr);
+ gpr_thd_new(&server_validator_id, "grpc_bad_client", thd_func, &a);
for (int i = 0; i < num_args; i++) {
grpc_run_client_side_validator(&args[i], i == (num_args - 1) ? flags : 0,
&sfd, client_cq);
@@ -234,6 +234,7 @@ void grpc_run_bad_client_test(
/* Shutdown. */
shutdown_client(&sfd.client);
+ gpr_thd_join(server_validator_id);
shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(a.server, shutdown_cq, nullptr);
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index 1af168e1f9..e7b2cafa35 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -253,15 +253,17 @@ static void actually_poll_server(void* arg) {
gpr_free(pa);
}
-static void poll_server_until_read_done(test_tcp_server* server,
- gpr_event* signal_when_done) {
+static gpr_thd_id poll_server_until_read_done(test_tcp_server* server,
+
+ gpr_event* signal_when_done) {
gpr_atm_rel_store(&state.done_atm, 0);
state.write_done = 0;
gpr_thd_id id;
poll_args* pa = static_cast<poll_args*>(gpr_malloc(sizeof(*pa)));
pa->server = server;
pa->signal_when_done = signal_when_done;
- gpr_thd_new(&id, "grpc_poll_server", actually_poll_server, pa, nullptr);
+ gpr_thd_new(&id, "grpc_poll_server", actually_poll_server, pa);
+ return id;
}
static void run_test(const char* response_payload,
@@ -281,9 +283,10 @@ static void run_test(const char* response_payload,
state.response_payload_length = response_payload_length;
/* poll server until sending out the response */
- poll_server_until_read_done(&test_server, &ev);
+ gpr_thd_id id = poll_server_until_read_done(&test_server, &ev);
start_rpc(server_port, expected_status, expected_detail);
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
+ gpr_thd_join(id);
/* clean up */
grpc_endpoint_shutdown(state.tcp,
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index 18e8310251..8546ef541f 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -550,10 +550,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
// Start proxy thread.
- gpr_thd_options opt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&opt);
- GPR_ASSERT(
- gpr_thd_new(&proxy->thd, "grpc_http_proxy", thread_main, proxy, &opt));
+ GPR_ASSERT(gpr_thd_new(&proxy->thd, "grpc_http_proxy", thread_main, proxy));
return proxy;
}
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index bc3b0ca35c..db49534899 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -76,7 +76,6 @@ static void request_call(grpc_end2end_proxy* proxy);
grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
grpc_channel_args* client_args,
grpc_channel_args* server_args) {
- gpr_thd_options opt = gpr_thd_options_default();
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
@@ -98,9 +97,8 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
grpc_server_start(proxy->server);
grpc_call_details_init(&proxy->new_call_details);
- gpr_thd_options_set_joinable(&opt);
GPR_ASSERT(
- gpr_thd_new(&proxy->thd, "grpc_end2end_proxy", thread_main, proxy, &opt));
+ gpr_thd_new(&proxy->thd, "grpc_end2end_proxy", thread_main, proxy));
request_call(proxy);
diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc
index a517ffa686..d4887137f8 100644
--- a/test/core/end2end/tests/connectivity.cc
+++ b/test/core/end2end/tests/connectivity.cc
@@ -50,7 +50,6 @@ static void test_connectivity(grpc_end2end_test_config config) {
grpc_connectivity_state state;
cq_verifier* cqv = cq_verifier_create(f.cq);
child_events ce;
- gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
grpc_channel_args client_args;
@@ -67,9 +66,7 @@ static void test_connectivity(grpc_end2end_test_config config) {
ce.channel = f.client;
ce.cq = f.cq;
gpr_event_init(&ce.started);
- gpr_thd_options_set_joinable(&thdopt);
- GPR_ASSERT(
- gpr_thd_new(&thdid, "grpc_connectivity", child_thread, &ce, &thdopt));
+ GPR_ASSERT(gpr_thd_new(&thdid, "grpc_connectivity", child_thread, &ce));
gpr_event_wait(&ce.started, gpr_inf_future(GPR_CLOCK_MONOTONIC));
diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc
index 9eaf57b631..1cfaefa686 100644
--- a/test/core/gpr/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -100,10 +100,7 @@ static void concurrent_test(void) {
gpr_thd_id thds[CONCURRENT_TEST_THREADS];
for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) {
- gpr_thd_options opt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&thds[i], "grpc_concurrent_test", concurrent_test_body, &args,
- &opt);
+ gpr_thd_new(&thds[i], "grpc_concurrent_test", concurrent_test_body, &args);
}
gpr_event_set(&args.ev_start, (void*)1);
diff --git a/test/core/gpr/cpu_test.cc b/test/core/gpr/cpu_test.cc
index 9f2c3f1923..c97facef7d 100644
--- a/test/core/gpr/cpu_test.cc
+++ b/test/core/gpr/cpu_test.cc
@@ -101,7 +101,7 @@ static void cpu_test(void) {
uint32_t i;
int cores_seen = 0;
struct cpu_test ct;
- gpr_thd_id thd;
+ gpr_thd_id* thd;
ct.ncores = gpr_cpu_num_cores();
GPR_ASSERT(ct.ncores > 0);
ct.nthreads = static_cast<int>(ct.ncores) * 3;
@@ -110,15 +110,22 @@ static void cpu_test(void) {
gpr_mu_init(&ct.mu);
gpr_cv_init(&ct.done_cv);
ct.is_done = 0;
- for (i = 0; i < ct.ncores * 3; i++) {
- GPR_ASSERT(
- gpr_thd_new(&thd, "grpc_cpu_test", &worker_thread, &ct, nullptr));
+
+ uint32_t nthreads = ct.ncores * 3;
+ thd = static_cast<gpr_thd_id*>(gpr_malloc(sizeof(thd[0]) * nthreads));
+
+ for (i = 0; i < nthreads; i++) {
+ GPR_ASSERT(gpr_thd_new(&thd[i], "grpc_cpu_test", &worker_thread, &ct));
}
gpr_mu_lock(&ct.mu);
while (!ct.is_done) {
gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&ct.mu);
+ for (i = 0; i < nthreads; i++) {
+ gpr_thd_join(thd[i]);
+ }
+ gpr_free(thd);
fprintf(stderr, "Saw cores [");
fflush(stderr);
for (i = 0; i < ct.ncores; i++) {
diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc
index 96813466c9..55998445f6 100644
--- a/test/core/gpr/mpscq_test.cc
+++ b/test/core/gpr/mpscq_test.cc
@@ -81,13 +81,10 @@ static void test_mt(void) {
gpr_mpscq q;
gpr_mpscq_init(&q);
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
ta[i].ctr = 0;
ta[i].q = &q;
ta[i].start = &start;
- GPR_ASSERT(
- gpr_thd_new(&thds[i], "grpc_mt_test", test_thread, &ta[i], &options));
+ GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_mt_test", test_thread, &ta[i]));
}
size_t num_done = 0;
size_t spins = 0;
@@ -153,13 +150,11 @@ static void test_mt_multipop(void) {
gpr_mpscq q;
gpr_mpscq_init(&q);
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
ta[i].ctr = 0;
ta[i].q = &q;
ta[i].start = &start;
- GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_multipop_test", test_thread, &ta[i],
- &options));
+ GPR_ASSERT(
+ gpr_thd_new(&thds[i], "grpc_multipop_test", test_thread, &ta[i]));
}
pull_args pa;
pa.ta = ta;
@@ -170,10 +165,8 @@ static void test_mt_multipop(void) {
pa.start = &start;
gpr_mu_init(&pa.mu);
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) {
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
- GPR_ASSERT(gpr_thd_new(&pull_thds[i], "grpc_multipop_pull", pull_thread,
- &pa, &options));
+ GPR_ASSERT(
+ gpr_thd_new(&pull_thds[i], "grpc_multipop_pull", pull_thread, &pa));
}
gpr_event_set(&start, (void*)1);
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) {
diff --git a/test/core/gpr/spinlock_test.cc b/test/core/gpr/spinlock_test.cc
index 9f182bc154..1392cff7ad 100644
--- a/test/core/gpr/spinlock_test.cc
+++ b/test/core/gpr/spinlock_test.cc
@@ -66,10 +66,7 @@ static void test_destroy(struct test* m) {
static void test_create_threads(struct test* m, void (*body)(void* arg)) {
int i;
for (i = 0; i != m->thread_count; i++) {
- gpr_thd_options opt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&opt);
- GPR_ASSERT(
- gpr_thd_new(&m->threads[i], "grpc_create_threads", body, m, &opt));
+ GPR_ASSERT(gpr_thd_new(&m->threads[i], "grpc_create_threads", body, m));
}
}
diff --git a/test/core/gpr/sync_test.cc b/test/core/gpr/sync_test.cc
index bafd91020b..d2d1f41775 100644
--- a/test/core/gpr/sync_test.cc
+++ b/test/core/gpr/sync_test.cc
@@ -134,6 +134,7 @@ int queue_remove(queue* q, int* head, gpr_timespec abs_deadline) {
/* Tests for gpr_mu and gpr_cv, and the queue example. */
struct test {
int threads; /* number of threads */
+ gpr_thd_id* thread_ids;
int64_t iterations; /* number of iterations per thread */
int64_t counter;
@@ -160,6 +161,8 @@ struct test {
static struct test* test_new(int threads, int64_t iterations, int incr_step) {
struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m)));
m->threads = threads;
+ m->thread_ids =
+ static_cast<gpr_thd_id*>(gpr_malloc(sizeof(*m->thread_ids) * threads));
m->iterations = iterations;
m->counter = 0;
m->thread_count = 0;
@@ -182,15 +185,15 @@ static void test_destroy(struct test* m) {
gpr_cv_destroy(&m->cv);
gpr_cv_destroy(&m->done_cv);
queue_destroy(&m->q);
+ gpr_free(m->thread_ids);
gpr_free(m);
}
/* Create m->threads threads, each running (*body)(m) */
static void test_create_threads(struct test* m, void (*body)(void* arg)) {
- gpr_thd_id id;
int i;
for (i = 0; i != m->threads; i++) {
- GPR_ASSERT(gpr_thd_new(&id, "grpc_create_threads", body, m, nullptr));
+ GPR_ASSERT(gpr_thd_new(&m->thread_ids[i], "grpc_create_threads", body, m));
}
}
@@ -201,6 +204,9 @@ static void test_wait(struct test* m) {
gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(&m->mu);
+ for (int i = 0; i != m->threads; i++) {
+ gpr_thd_join(m->thread_ids[i]);
+ }
}
/* Get an integer thread id in the raneg 0..threads-1 */
@@ -245,13 +251,16 @@ static void test(const char* name, void (*body)(void* m),
fprintf(stderr, " %ld", static_cast<long>(iterations));
fflush(stderr);
m = test_new(10, iterations, incr_step);
+ gpr_thd_id extra_id;
if (extra != nullptr) {
- gpr_thd_id id;
- GPR_ASSERT(gpr_thd_new(&id, name, extra, m, nullptr));
+ GPR_ASSERT(gpr_thd_new(&extra_id, name, extra, m));
m->done++; /* one more thread to wait for */
}
test_create_threads(m, body);
test_wait(m);
+ if (extra != nullptr) {
+ gpr_thd_join(extra_id);
+ }
if (m->counter != m->threads * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
static_cast<long>(m->counter), m->threads,
diff --git a/test/core/gpr/thd_test.cc b/test/core/gpr/thd_test.cc
index 18bbaae6c9..47e9a22fd8 100644
--- a/test/core/gpr/thd_test.cc
+++ b/test/core/gpr/thd_test.cc
@@ -38,7 +38,7 @@ struct test {
};
/* A Thread body. Decrement t->n, and if is becomes zero, set t->done. */
-static void thd_body(void* v) {
+static void thd_body1(void* v) {
struct test* t = static_cast<struct test*>(v);
gpr_mu_lock(&t->mu);
t->n--;
@@ -49,45 +49,38 @@ static void thd_body(void* v) {
gpr_mu_unlock(&t->mu);
}
-static void thd_body_joinable(void* v) {}
-
-/* Test thread options work as expected */
-static void test_options(void) {
- gpr_thd_options options = gpr_thd_options_default();
- GPR_ASSERT(!gpr_thd_options_is_joinable(&options));
- GPR_ASSERT(gpr_thd_options_is_detached(&options));
- gpr_thd_options_set_joinable(&options);
- GPR_ASSERT(gpr_thd_options_is_joinable(&options));
- GPR_ASSERT(!gpr_thd_options_is_detached(&options));
- gpr_thd_options_set_detached(&options);
- GPR_ASSERT(!gpr_thd_options_is_joinable(&options));
- GPR_ASSERT(gpr_thd_options_is_detached(&options));
-}
-
-/* Test that we can create a number of threads and wait for them. */
-static void test(void) {
+/* Test that we can create a number of threads, wait for them, and join them. */
+static void test1(void) {
int i;
- gpr_thd_id thd;
gpr_thd_id thds[NUM_THREADS];
struct test t;
- gpr_thd_options options = gpr_thd_options_default();
gpr_mu_init(&t.mu);
gpr_cv_init(&t.done_cv);
t.n = NUM_THREADS;
t.is_done = 0;
for (i = 0; i < NUM_THREADS; i++) {
- GPR_ASSERT(gpr_thd_new(&thd, "grpc_thread_test", &thd_body, &t, nullptr));
+ GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_thread_body1_test", &thd_body1, &t));
}
gpr_mu_lock(&t.mu);
while (!t.is_done) {
gpr_cv_wait(&t.done_cv, &t.mu, gpr_inf_future(GPR_CLOCK_REALTIME));
}
gpr_mu_unlock(&t.mu);
+ for (i = 0; i < NUM_THREADS; i++) {
+ gpr_thd_join(thds[i]);
+ }
GPR_ASSERT(t.n == 0);
- gpr_thd_options_set_joinable(&options);
+}
+
+static void thd_body2(void* v) {}
+
+/* Test that we can create a number of threads and join them. */
+static void test2(void) {
+ int i;
+ gpr_thd_id thds[NUM_THREADS];
for (i = 0; i < NUM_THREADS; i++) {
- GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_joinable_thread_test",
- &thd_body_joinable, nullptr, &options));
+ GPR_ASSERT(
+ gpr_thd_new(&thds[i], "grpc_thread_body2_test", &thd_body2, nullptr));
}
for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(thds[i]);
@@ -98,7 +91,7 @@ static void test(void) {
int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
- test_options();
- test();
+ test1();
+ test2();
return 0;
}
diff --git a/test/core/gpr/tls_test.cc b/test/core/gpr/tls_test.cc
index 1e4534dc5a..f3f0864d3d 100644
--- a/test/core/gpr/tls_test.cc
+++ b/test/core/gpr/tls_test.cc
@@ -46,7 +46,6 @@ static void thd_body(void* arg) {
/* ------------------------------------------------- */
int main(int argc, char* argv[]) {
- gpr_thd_options opt = gpr_thd_options_default();
int i;
gpr_thd_id threads[NUM_THREADS];
@@ -54,10 +53,8 @@ int main(int argc, char* argv[]) {
gpr_tls_init(&test_var);
- gpr_thd_options_set_joinable(&opt);
-
for (i = 0; i < NUM_THREADS; i++) {
- gpr_thd_new(&threads[i], "grpc_tls_test", thd_body, nullptr, &opt);
+ gpr_thd_new(&threads[i], "grpc_tls_test", thd_body, nullptr);
}
for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(threads[i]);
diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc
index fe2ab251e3..2581eb525c 100644
--- a/test/core/handshake/client_ssl.cc
+++ b/test/core/handshake/client_ssl.cc
@@ -230,12 +230,9 @@ static bool client_ssl_test(char* server_alpn_preferred) {
GPR_ASSERT(server_socket > 0 && port > 0);
// Launch the TLS server thread.
- gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
- gpr_thd_options_set_joinable(&thdopt);
server_args args = {server_socket, server_alpn_preferred};
- GPR_ASSERT(gpr_thd_new(&thdid, "grpc_client_ssl_test", server_thread, &args,
- &thdopt));
+ GPR_ASSERT(gpr_thd_new(&thdid, "grpc_client_ssl_test", server_thread, &args));
// Load key pair and establish client SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc
index d202a7cfd6..a2d389954f 100644
--- a/test/core/handshake/server_ssl_common.cc
+++ b/test/core/handshake/server_ssl_common.cc
@@ -138,11 +138,8 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
gpr_event_init(&client_handshake_complete);
// Launch the gRPC server thread.
- gpr_thd_options thdopt = gpr_thd_options_default();
gpr_thd_id thdid;
- gpr_thd_options_set_joinable(&thdopt);
- GPR_ASSERT(
- gpr_thd_new(&thdid, "grpc_ssl_test", server_thread, &port, &thdopt));
+ GPR_ASSERT(gpr_thd_new(&thdid, "grpc_ssl_test", server_thread, &port));
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc
index 8426b3d233..0cd63bd973 100644
--- a/test/core/iomgr/combiner_test.cc
+++ b/test/core/iomgr/combiner_test.cc
@@ -100,13 +100,11 @@ static void test_execute_many(void) {
gpr_thd_id thds[100];
thd_args ta[GPR_ARRAY_SIZE(thds)];
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
ta[i].ctr = 0;
ta[i].lock = lock;
gpr_event_init(&ta[i].done);
- GPR_ASSERT(gpr_thd_new(&thds[i], "grpc_execute_many", execute_many_loop,
- &ta[i], &options));
+ GPR_ASSERT(
+ gpr_thd_new(&thds[i], "grpc_execute_many", execute_many_loop, &ta[i]));
}
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
GPR_ASSERT(gpr_event_wait(&ta[i].done,
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index 02d11271ec..5c30843588 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -261,9 +261,7 @@ static void test_threading(void) {
gpr_thd_id thds[10];
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
- gpr_thd_options opt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&thds[i], "test_thread", test_threading_loop, &shared, &opt);
+ gpr_thd_new(&thds[i], "test_thread", test_threading_loop, &shared);
}
grpc_wakeup_fd fd;
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&fd)));
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index 341579f178..6a1564dd69 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -38,6 +38,7 @@ static gpr_timespec test_deadline(void) {
}
typedef struct args_struct {
+ gpr_thd_id id;
gpr_event ev;
grpc_resolved_addresses* addrs;
gpr_atm done_atm;
@@ -59,6 +60,7 @@ void args_init(args_struct* args) {
void args_finish(args_struct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
+ gpr_thd_join(args->id);
grpc_resolved_addresses_destroy(args->addrs);
grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
grpc_pollset_set_destroy(args->pollset_set);
@@ -101,8 +103,7 @@ static void actually_poll(void* argsp) {
static void poll_pollset_until_request_done(args_struct* args) {
gpr_atm_rel_store(&args->done_atm, 0);
- gpr_thd_id id;
- gpr_thd_new(&id, "grpc_poll_pollset", actually_poll, args, nullptr);
+ gpr_thd_new(&args->id, "grpc_poll_pollset", actually_poll, args);
}
static void must_succeed(void* argsp, grpc_error* err) {
diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc
index 68dcb50aa6..d77a3ec0b4 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.cc
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -104,7 +104,6 @@ void test_poll_cv_trigger(void) {
struct pollfd pfds[6];
poll_args pargs;
gpr_thd_id t_id;
- gpr_thd_options opt;
GPR_ASSERT(grpc_wakeup_fd_init(&cvfd1) == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_wakeup_fd_init(&cvfd2) == GRPC_ERROR_NONE);
@@ -135,9 +134,7 @@ void test_poll_cv_trigger(void) {
pargs.timeout = 1000;
pargs.result = -2;
- opt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&opt);
- gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs);
// Wakeup wakeup_fd not listening for events
GPR_ASSERT(grpc_wakeup_fd_wakeup(&cvfd1) == GRPC_ERROR_NONE);
@@ -153,7 +150,7 @@ void test_poll_cv_trigger(void) {
// Pollin on socket fd
pargs.timeout = -1;
pargs.result = -2;
- gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs);
trigger_socket_event();
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 1);
@@ -167,7 +164,7 @@ void test_poll_cv_trigger(void) {
// Pollin on wakeup fd
reset_socket_event();
pargs.result = -2;
- gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs);
GPR_ASSERT(grpc_wakeup_fd_wakeup(&cvfd2) == GRPC_ERROR_NONE);
gpr_thd_join(t_id);
@@ -181,7 +178,7 @@ void test_poll_cv_trigger(void) {
// Pollin on wakeupfd before poll()
pargs.result = -2;
- gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs);
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 1);
@@ -198,7 +195,7 @@ void test_poll_cv_trigger(void) {
reset_socket_event();
GPR_ASSERT(grpc_wakeup_fd_consume_wakeup(&cvfd1) == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_wakeup_fd_consume_wakeup(&cvfd2) == GRPC_ERROR_NONE);
- gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs, &opt);
+ gpr_thd_new(&t_id, "grpc_background_poll", &background_poll, &pargs);
gpr_thd_join(t_id);
GPR_ASSERT(pargs.result == 0);
diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc
index 33716b9d4a..b90ad8d44d 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.cc
+++ b/test/core/network_benchmarks/low_level_ping_pong.cc
@@ -586,8 +586,10 @@ static int run_benchmark(const char* socket_type, thread_args* client_args,
gpr_log(GPR_INFO, "Starting test %s %s %zu", client_args->strategy_name,
socket_type, client_args->msg_size);
- gpr_thd_new(&tid, "server_thread", server_thread_wrap, server_args, nullptr);
+ gpr_thd_new(&tid, "server_thread", server_thread_wrap, server_args);
client_thread(client_args);
+ gpr_thd_join(tid);
+
return 0;
}
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index 81319f4df4..37232a4fb1 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -80,14 +80,12 @@ static void test_too_many_plucks(void) {
grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)];
struct thread_state thread_states[GPR_ARRAY_SIZE(tags)];
- gpr_thd_options thread_options = gpr_thd_options_default();
grpc_core::ExecCtx exec_ctx;
unsigned i, j;
LOG_TEST("test_too_many_plucks");
cc = grpc_completion_queue_create_for_pluck(nullptr);
- gpr_thd_options_set_joinable(&thread_options);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
tags[i] = create_test_tag();
@@ -96,8 +94,8 @@ static void test_too_many_plucks(void) {
}
thread_states[i].cc = cc;
thread_states[i].tag = tags[i];
- gpr_thd_new(thread_ids + i, "grpc_pluck_test", pluck_one, thread_states + i,
- &thread_options);
+ gpr_thd_new(thread_ids + i, "grpc_pluck_test", pluck_one,
+ thread_states + i);
}
/* wait until all other threads are plucking */
@@ -220,8 +218,9 @@ static void test_threading(size_t producers, size_t consumers) {
"test_threading", producers, consumers);
/* start all threads: they will wait for phase1 */
+ gpr_thd_id* ids = static_cast<gpr_thd_id*>(
+ gpr_malloc(sizeof(*ids) * (producers + consumers)));
for (i = 0; i < producers + consumers; i++) {
- gpr_thd_id id;
gpr_event_init(&options[i].on_started);
gpr_event_init(&options[i].on_phase1_done);
gpr_event_init(&options[i].on_finished);
@@ -230,10 +229,9 @@ static void test_threading(size_t producers, size_t consumers) {
options[i].events_triggered = 0;
options[i].cc = cc;
options[i].id = optid++;
- GPR_ASSERT(gpr_thd_new(&id,
- i < producers ? "grpc_producer" : "grpc_consumer",
- i < producers ? producer_thread : consumer_thread,
- options + i, nullptr));
+ GPR_ASSERT(gpr_thd_new(
+ &ids[i], i < producers ? "grpc_producer" : "grpc_consumer",
+ i < producers ? producer_thread : consumer_thread, options + i));
gpr_event_wait(&options[i].on_started, ten_seconds_time());
}
@@ -266,6 +264,11 @@ static void test_threading(size_t producers, size_t consumers) {
/* destroy the completion channel */
grpc_completion_queue_destroy(cc);
+ for (i = 0; i < producers + consumers; i++) {
+ gpr_thd_join(ids[i]);
+ }
+ gpr_free(ids);
+
/* verify that everything was produced and consumed */
for (i = 0; i < producers + consumers; i++) {
if (i < producers) {
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 95af4abd48..974263d914 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -176,14 +176,11 @@ int run_concurrent_connectivity_test() {
gpr_thd_id server;
char* localhost = gpr_strdup("localhost:54321");
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
/* First round, no server */
gpr_log(GPR_DEBUG, "Wave 1");
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], "grpc_wave_1", create_loop_destroy, localhost,
- &options);
+ gpr_thd_new(&threads[i], "grpc_wave_1", create_loop_destroy, localhost);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -199,11 +196,10 @@ int run_concurrent_connectivity_test() {
args.cq = grpc_completion_queue_create_for_next(nullptr);
grpc_server_register_completion_queue(args.server, args.cq, nullptr);
grpc_server_start(args.server);
- gpr_thd_new(&server, "grpc_wave_2_server", server_thread, &args, &options);
+ gpr_thd_new(&server, "grpc_wave_2_server", server_thread, &args);
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], "grpc_wave_2", create_loop_destroy, args.addr,
- &options);
+ gpr_thd_new(&threads[i], "grpc_wave_2", create_loop_destroy, args.addr);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -220,13 +216,11 @@ int run_concurrent_connectivity_test() {
args.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args.pollset, &args.mu);
gpr_event_init(&args.ready);
- gpr_thd_new(&server, "grpc_wave_3_server", bad_server_thread, &args,
- &options);
+ gpr_thd_new(&server, "grpc_wave_3_server", bad_server_thread, &args);
gpr_event_wait(&args.ready, gpr_inf_future(GPR_CLOCK_MONOTONIC));
for (size_t i = 0; i < NUM_THREADS; ++i) {
- gpr_thd_new(&threads[i], "grpc_wave_3", create_loop_destroy, args.addr,
- &options);
+ gpr_thd_new(&threads[i], "grpc_wave_3", create_loop_destroy, args.addr);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
@@ -281,12 +275,10 @@ int run_concurrent_watches_with_short_timeouts_test() {
gpr_thd_id threads[NUM_THREADS];
char* localhost = gpr_strdup("localhost:54321");
- gpr_thd_options options = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&options);
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_new(&threads[i], "grpc_short_watches", watches_with_short_timeouts,
- localhost, &options);
+ localhost);
}
for (size_t i = 0; i < NUM_THREADS; ++i) {
gpr_thd_join(threads[i]);
diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc
index 428d17ff1b..8ca7b4f5dc 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -68,9 +68,7 @@ static void run_test(const test_fixture* fixture) {
server_thread_args sta = {server, server_cq};
gpr_thd_id server_thread;
- gpr_thd_options thdopt = gpr_thd_options_default();
- gpr_thd_options_set_joinable(&thdopt);
- gpr_thd_new(&server_thread, "grpc_server", server_thread_func, &sta, &thdopt);
+ gpr_thd_new(&server_thread, "grpc_server", server_thread_func, &sta);
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
grpc_channel* channels[NUM_CONNECTIONS];