* Check for possible stops and suspensions while executing a * casueword or similar transiently failing operation. * * The sleep argument controls whether the function can handle a stop * request itself or it should return ERESTART and the request is * proceed at the kernel/user boundary in ast. * * Typically, when retrying due to casueword(9) failure (rv == 1), we * should handle the stop
| 1429 | * handle it at all, and simply return EINTR. |
| 1430 | */ |
| 1431 | int |
| 1432 | thread_check_susp(struct thread *td, bool sleep) |
| 1433 | { |
| 1434 | struct proc *p; |
| 1435 | int error; |
| 1436 | |
| 1437 | /* |
| 1438 | * The check for TDF_NEEDSUSPCHK is racy, but it is enough to |
| 1439 | * eventually break the lockstep loop. |
| 1440 | */ |
| 1441 | if ((td->td_flags & TDF_NEEDSUSPCHK) == 0) |
| 1442 | return (0); |
| 1443 | error = 0; |
| 1444 | p = td->td_proc; |
| 1445 | PROC_LOCK(p); |
| 1446 | if (p->p_flag & P_SINGLE_EXIT) |
| 1447 | error = EINTR; |
| 1448 | else if (P_SHOULDSTOP(p) || |
| 1449 | ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND))) |
| 1450 | error = sleep ? thread_suspend_check(0) : ERESTART; |
| 1451 | PROC_UNLOCK(p); |
| 1452 | return (error); |
| 1453 | } |
| 1454 | |
| 1455 | void |
| 1456 | thread_suspend_switch(struct thread *td, struct proc *p) |
no test coverage detected