* This function always succeeds, so we don't have to
* check its return value.
*/
- sem_wait(&(mbox->mb_rsem));
+ ret_val = sem_wait(&(mbox->mb_rsem));
- /* retrieve the message */
- *dst = mbox->mb_msg;
-
- /*
- * Rendevouz with the sender: Let them know we have
- * received their message.
- */
- ret_val = sem_post(&(mbox->mb_ssem));
+ if(!ret_val) {
+ /* retrieve the message */
+ *dst = mbox->mb_msg;
+
+ /*
+ * Rendevouz with the sender: Let them know we have
+ * received their message.
+ */
+ ret_val = sem_post(&(mbox->mb_ssem));
+ }
}
return(ret_val);
* message can be retrieved. The sending and receiving tasks will
* rendevouz during the message transmission, meaning that the sender
* will wait for the message to be retrieved by a receiving task.
+ * If a signal is delivered to the task while it is waiting for a
+ * message to be put into the mailbox, this function will return early,
+ * leaving the mailbox unmodified.
*
* RETURN VALUE
* 0 A message was successfully retrieved from the mailbox
* -EINVAL Invalid mailbox specified
+ * -EINTR The function call was interrupted by a signal
* -EOVERFLOW An overflow occured during the rendevouz. This error
* means that the mailbox was overwritten with invalid
* data due to a kernel bug