* Claim another reference to a ucred structure. */
| 2010 | * Claim another reference to a ucred structure. |
| 2011 | */ |
| 2012 | struct ucred * |
| 2013 | crhold(struct ucred *cr) |
| 2014 | { |
| 2015 | struct thread *td; |
| 2016 | |
| 2017 | td = curthread; |
| 2018 | if (__predict_true(td->td_realucred == cr)) { |
| 2019 | KASSERT(cr->cr_users > 0, ("%s: users %d not > 0 on cred %p", |
| 2020 | __func__, cr->cr_users, cr)); |
| 2021 | td->td_ucredref++; |
| 2022 | return (cr); |
| 2023 | } |
| 2024 | mtx_lock(&cr->cr_mtx); |
| 2025 | cr->cr_ref++; |
| 2026 | mtx_unlock(&cr->cr_mtx); |
| 2027 | return (cr); |
| 2028 | } |
| 2029 | |
| 2030 | /* |
| 2031 | * Free a cred structure. Throws away space when ref count gets to 0. |
no test coverage detected