* Record a select request. */
| 1784 | * Record a select request. |
| 1785 | */ |
| 1786 | void |
| 1787 | selrecord(struct thread *selector, struct selinfo *sip) |
| 1788 | { |
| 1789 | struct selfd *sfp; |
| 1790 | struct seltd *stp; |
| 1791 | struct mtx *mtxp; |
| 1792 | |
| 1793 | stp = selector->td_sel; |
| 1794 | /* |
| 1795 | * Don't record when doing a rescan. |
| 1796 | */ |
| 1797 | if (stp->st_flags & SELTD_RESCAN) |
| 1798 | return; |
| 1799 | /* |
| 1800 | * Grab one of the preallocated descriptors. |
| 1801 | */ |
| 1802 | sfp = NULL; |
| 1803 | if ((sfp = stp->st_free1) != NULL) |
| 1804 | stp->st_free1 = NULL; |
| 1805 | else if ((sfp = stp->st_free2) != NULL) |
| 1806 | stp->st_free2 = NULL; |
| 1807 | else |
| 1808 | panic("selrecord: No free selfd on selq"); |
| 1809 | mtxp = sip->si_mtx; |
| 1810 | if (mtxp == NULL) |
| 1811 | mtxp = mtx_pool_find(mtxpool_select, sip); |
| 1812 | /* |
| 1813 | * Initialize the sfp and queue it in the thread. |
| 1814 | */ |
| 1815 | sfp->sf_si = sip; |
| 1816 | sfp->sf_mtx = mtxp; |
| 1817 | STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link); |
| 1818 | /* |
| 1819 | * Now that we've locked the sip, check for initialization. |
| 1820 | */ |
| 1821 | mtx_lock(mtxp); |
| 1822 | if (sip->si_mtx == NULL) { |
| 1823 | sip->si_mtx = mtxp; |
| 1824 | TAILQ_INIT(&sip->si_tdlist); |
| 1825 | } |
| 1826 | /* |
| 1827 | * Add this thread to the list of selfds listening on this selinfo. |
| 1828 | */ |
| 1829 | TAILQ_INSERT_TAIL(&sip->si_tdlist, sfp, sf_threads); |
| 1830 | mtx_unlock(sip->si_mtx); |
| 1831 | } |
| 1832 | |
| 1833 | /* Wake up a selecting thread. */ |
| 1834 | void |
no test coverage detected