Fix msgsnd(3)/msgrcv(3) deadlock under heavy resource pressure by timing out

msgsnd and rechecking resources.  This problem was found while I was running
Linux Test Project test suite (test cases: msgctl08, msgctl09).
Change `msgwait' to `msgsnd' and `msgrcv' to distinguish its sleeping
conditions.  Few cosmetic changes to debugging messages.
This commit is contained in:
jkim 2006-11-17 20:43:01 +00:00
parent 500c68689f
commit edc10a6695

View File

@ -780,12 +780,16 @@ msgsnd(td, uap)
msqkptr->u.msg_perm.mode |= MSG_LOCKED;
we_own_it = 1;
}
DPRINTF(("goodnight\n"));
DPRINTF(("msgsnd: goodnight\n"));
error = msleep(msqkptr, &msq_mtx, (PZERO - 4) | PCATCH,
"msgwait", 0);
DPRINTF(("good morning, error=%d\n", error));
"msgsnd", hz);
DPRINTF(("msgsnd: good morning, error=%d\n", error));
if (we_own_it)
msqkptr->u.msg_perm.mode &= ~MSG_LOCKED;
if (error == EWOULDBLOCK) {
DPRINTF(("msgsnd: timed out\n"));
continue;
}
if (error != 0) {
DPRINTF(("msgsnd: interrupted system call\n"));
error = EINTR;
@ -1178,11 +1182,11 @@ msgrcv(td, uap)
DPRINTF(("msgrcv: goodnight\n"));
error = msleep(msqkptr, &msq_mtx, (PZERO - 4) | PCATCH,
"msgwait", 0);
"msgrcv", 0);
DPRINTF(("msgrcv: good morning (error=%d)\n", error));
if (error != 0) {
DPRINTF(("msgsnd: interrupted system call\n"));
DPRINTF(("msgrcv: interrupted system call\n"));
error = EINTR;
goto done2;
}