| 1243 | } |
| 1244 | |
| 1245 | static int |
| 1246 | closefp_impl(struct filedesc *fdp, int fd, struct file *fp, struct thread *td, |
| 1247 | bool audit) |
| 1248 | { |
| 1249 | int error; |
| 1250 | |
| 1251 | FILEDESC_XLOCK_ASSERT(fdp); |
| 1252 | |
| 1253 | /* |
| 1254 | * We now hold the fp reference that used to be owned by the |
| 1255 | * descriptor array. We have to unlock the FILEDESC *AFTER* |
| 1256 | * knote_fdclose to prevent a race of the fd getting opened, a knote |
| 1257 | * added, and deleteing a knote for the new fd. |
| 1258 | */ |
| 1259 | if (__predict_false(!TAILQ_EMPTY(&fdp->fd_kqlist))) |
| 1260 | knote_fdclose(td, fd); |
| 1261 | |
| 1262 | /* |
| 1263 | * We need to notify mqueue if the object is of type mqueue. |
| 1264 | */ |
| 1265 | if (__predict_false(fp->f_type == DTYPE_MQUEUE)) |
| 1266 | mq_fdclose(td, fd, fp); |
| 1267 | FILEDESC_XUNLOCK(fdp); |
| 1268 | |
| 1269 | #ifdef AUDIT |
| 1270 | if (AUDITING_TD(td) && audit) |
| 1271 | audit_sysclose(td, fd, fp); |
| 1272 | #endif |
| 1273 | error = closef(fp, td); |
| 1274 | |
| 1275 | /* |
| 1276 | * All paths leading up to closefp() will have already removed or |
| 1277 | * replaced the fd in the filedesc table, so a restart would not |
| 1278 | * operate on the same file. |
| 1279 | */ |
| 1280 | if (error == ERESTART) |
| 1281 | error = EINTR; |
| 1282 | |
| 1283 | return (error); |
| 1284 | } |
| 1285 | |
| 1286 | static int |
| 1287 | closefp_hl(struct filedesc *fdp, int fd, struct file *fp, struct thread *td, |
no test coverage detected