| 352 | */ |
| 353 | |
| 354 | void |
| 355 | cupsdStopSystemMonitor(void) |
| 356 | { |
| 357 | CFRunLoopRef rl; /* The event handler runloop */ |
| 358 | |
| 359 | |
| 360 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStopSystemMonitor()"); |
| 361 | |
| 362 | if (SysEventThread) |
| 363 | { |
| 364 | /* |
| 365 | * Make sure the thread has completed it's initialization and |
| 366 | * stored it's runloop reference in the shared global. |
| 367 | */ |
| 368 | |
| 369 | pthread_mutex_lock(&SysEventThreadMutex); |
| 370 | |
| 371 | if (!SysEventRunloop) |
| 372 | pthread_cond_wait(&SysEventThreadCond, &SysEventThreadMutex); |
| 373 | |
| 374 | rl = SysEventRunloop; |
| 375 | SysEventRunloop = NULL; |
| 376 | |
| 377 | pthread_mutex_unlock(&SysEventThreadMutex); |
| 378 | |
| 379 | if (rl) |
| 380 | CFRunLoopStop(rl); |
| 381 | |
| 382 | pthread_join(SysEventThread, NULL); |
| 383 | pthread_mutex_destroy(&SysEventThreadMutex); |
| 384 | pthread_cond_destroy(&SysEventThreadCond); |
| 385 | } |
| 386 | |
| 387 | if (SysEventPipes[0] >= 0) |
| 388 | { |
| 389 | cupsdRemoveSelect(SysEventPipes[0]); |
| 390 | cupsdClosePipe(SysEventPipes); |
| 391 | } |
| 392 | |
| 393 | if (PSToken != 0) |
| 394 | { |
| 395 | notify_cancel(PSToken); |
| 396 | PSToken = 0; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | |
| 401 | /* |
no test coverage detected