| 308 | } |
| 309 | |
| 310 | static bool |
| 311 | background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) { |
| 312 | if (info == &background_thread_info[0]) { |
| 313 | malloc_mutex_assert_owner(tsd_tsdn(tsd), |
| 314 | &background_thread_lock); |
| 315 | } else { |
| 316 | malloc_mutex_assert_not_owner(tsd_tsdn(tsd), |
| 317 | &background_thread_lock); |
| 318 | } |
| 319 | |
| 320 | pre_reentrancy(tsd, NULL); |
| 321 | malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx); |
| 322 | bool has_thread; |
| 323 | assert(info->state != background_thread_paused); |
| 324 | if (info->state == background_thread_started) { |
| 325 | has_thread = true; |
| 326 | info->state = background_thread_stopped; |
| 327 | pthread_cond_signal(&info->cond); |
| 328 | } else { |
| 329 | has_thread = false; |
| 330 | } |
| 331 | malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx); |
| 332 | |
| 333 | if (!has_thread) { |
| 334 | post_reentrancy(tsd); |
| 335 | return false; |
| 336 | } |
| 337 | void *ret; |
| 338 | if (pthread_join(info->thread, &ret)) { |
| 339 | post_reentrancy(tsd); |
| 340 | return true; |
| 341 | } |
| 342 | assert(ret == NULL); |
| 343 | n_background_threads--; |
| 344 | post_reentrancy(tsd); |
| 345 | |
| 346 | return false; |
| 347 | } |
| 348 | |
| 349 | static void *background_thread_entry(void *ind_arg); |
| 350 |
no test coverage detected