* Do a wakeup when a selectable event occurs. */
| 1848 | * Do a wakeup when a selectable event occurs. |
| 1849 | */ |
| 1850 | static void |
| 1851 | doselwakeup(struct selinfo *sip, int pri) |
| 1852 | { |
| 1853 | struct selfd *sfp; |
| 1854 | struct selfd *sfn; |
| 1855 | struct seltd *stp; |
| 1856 | |
| 1857 | /* If it's not initialized there can't be any waiters. */ |
| 1858 | if (sip->si_mtx == NULL) |
| 1859 | return; |
| 1860 | /* |
| 1861 | * Locking the selinfo locks all selfds associated with it. |
| 1862 | */ |
| 1863 | mtx_lock(sip->si_mtx); |
| 1864 | TAILQ_FOREACH_SAFE(sfp, &sip->si_tdlist, sf_threads, sfn) { |
| 1865 | /* |
| 1866 | * Once we remove this sfp from the list and clear the |
| 1867 | * sf_si seltdclear will know to ignore this si. |
| 1868 | */ |
| 1869 | TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads); |
| 1870 | stp = sfp->sf_td; |
| 1871 | mtx_lock(&stp->st_mtx); |
| 1872 | stp->st_flags |= SELTD_PENDING; |
| 1873 | cv_broadcastpri(&stp->st_wait, pri); |
| 1874 | mtx_unlock(&stp->st_mtx); |
| 1875 | /* |
| 1876 | * Paired with selfdfree. |
| 1877 | * |
| 1878 | * Storing this only after the wakeup provides an invariant that |
| 1879 | * stp is not used after selfdfree returns. |
| 1880 | */ |
| 1881 | atomic_store_rel_ptr((uintptr_t *)&sfp->sf_si, (uintptr_t)NULL); |
| 1882 | } |
| 1883 | mtx_unlock(sip->si_mtx); |
| 1884 | } |
| 1885 | |
| 1886 | static void |
| 1887 | seltdinit(struct thread *td) |
no test coverage detected