diff options
author | Sree Kuchibhotla <sreek@google.com> | 2017-11-06 16:47:33 -0800 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2017-11-07 09:12:08 -0800 |
commit | 9a0db888855e0905946ab476892ba697a6a9200d (patch) | |
tree | 4e843894280f262fce5e1b696d3476f5f7513501 | |
parent | 4cd04b3cd0833e97fc6a65ede8653961a0cf52a3 (diff) |
Fix TSAN issue in backup poller
-rw-r--r-- | src/core/ext/filters/client_channel/backup_poller.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 466bf86bc0..45b2464e27 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -143,9 +143,16 @@ void grpc_client_channel_start_backup_polling( grpc_exec_ctx_now(exec_ctx) + g_poll_interval_ms, &g_poller->run_poller_closure); } + gpr_ref(&g_poller->refs); + /* Get a reference to g_poller->pollset before releasing g_poller_mu to make + * TSAN happy. Otherwise, reading from g_poller (i.e g_poller->pollset) after + * releasing the lock and setting g_poller to NULL in g_poller_unref() is + * being flagged as a data-race by TSAN */ + grpc_pollset *pollset = g_poller->pollset; gpr_mu_unlock(&g_poller_mu); - grpc_pollset_set_add_pollset(exec_ctx, interested_parties, g_poller->pollset); + + grpc_pollset_set_add_pollset(exec_ctx, interested_parties, pollset); } void grpc_client_channel_stop_backup_polling( |