Preserve the order of IPC messages between two parties.

Currently a sequence of messages between a sender A and a receiver B of the
form: A.asynsend(M1, B); A.send(M2, B) may result in the receiver receiving
M1 first and then M2 or viceversa. This patch makes sure that the original
order M1, M2 is always preserved.

Note that the order of a hypotetical sequence A.asynsend(M1, B);
A.asynsend(M2, B) is already guaranteed by the implementation of
asynsend by design. Other senda-based wrappers can define their own
semantics.
This commit is contained in:
Cristiano Giuffrida 2010-03-27 00:09:22 +00:00
parent 8e5a82fd49
commit 9192dbecc9

View file

@ -684,6 +684,20 @@ int flags;
}
}
/* Check if there are pending senda(). */
if (caller_ptr->p_misc_flags & MF_ASYNMSG)
{
if (src_e != ANY)
r= try_one(proc_addr(src_p), caller_ptr, NULL);
else
r= try_async(caller_ptr);
if (r == OK) {
IPC_STATUS_ADD(caller_ptr, IPC_STATUS_CALL_TO(SENDA));
return OK; /* Got a message */
}
}
/* Check caller queue. Use pointer pointers to keep code simple. */
xpp = &caller_ptr->p_caller_q;
while (*xpp != NIL_PROC) {
@ -706,19 +720,6 @@ int flags;
}
xpp = &(*xpp)->p_q_link; /* proceed to next */
}
if (caller_ptr->p_misc_flags & MF_ASYNMSG)
{
if (src_e != ANY)
r= try_one(proc_addr(src_p), caller_ptr, NULL);
else
r= try_async(caller_ptr);
if (r == OK) {
IPC_STATUS_ADD(caller_ptr, IPC_STATUS_CALL_TO(SENDA));
return OK; /* Got a message */
}
}
}
/* No suitable message is available or the caller couldn't send in SENDREC.