| 230 | } |
| 231 | |
| 232 | static bool |
| 233 | background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) { |
| 234 | if (info == &background_thread_info[0]) { |
| 235 | malloc_mutex_assert_owner(tsd_tsdn(tsd), |
| 236 | &background_thread_lock); |
| 237 | } else { |
| 238 | malloc_mutex_assert_not_owner(tsd_tsdn(tsd), |
| 239 | &background_thread_lock); |
| 240 | } |
| 241 | |
| 242 | pre_reentrancy(tsd, NULL); |
| 243 | malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx); |
| 244 | bool has_thread; |
| 245 | assert(info->state != background_thread_paused); |
| 246 | if (info->state == background_thread_started) { |
| 247 | has_thread = true; |
| 248 | info->state = background_thread_stopped; |
| 249 | pthread_cond_signal(&info->cond); |
| 250 | } else { |
| 251 | has_thread = false; |
| 252 | } |
| 253 | malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx); |
| 254 | |
| 255 | if (!has_thread) { |
| 256 | post_reentrancy(tsd); |
| 257 | return false; |
| 258 | } |
| 259 | void *ret; |
| 260 | if (pthread_join(info->thread, &ret)) { |
| 261 | post_reentrancy(tsd); |
| 262 | return true; |
| 263 | } |
| 264 | assert(ret == NULL); |
| 265 | n_background_threads--; |
| 266 | post_reentrancy(tsd); |
| 267 | |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | static void *background_thread_entry(void *ind_arg); |
| 272 |
no test coverage detected