]> git.corax.cc Git - corax/commitdiff
kernel/core: Make mailbox_get() return -EINTR if the call to sem_wait() failed
authorMatthias Kruk <m@m10k.eu>
Sat, 4 Apr 2020 15:57:57 +0000 (00:57 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 4 Apr 2020 16:00:17 +0000 (01:00 +0900)
kernel/core/mailbox.c
kernel/core/mailbox.h

index 116799573f83b5878333b0e3d7d6843cd993fb67..1510e024e2b28057ed36d0ea83d8184d057a670f 100644 (file)
@@ -94,16 +94,18 @@ int mailbox_get(struct mailbox *mbox, void **dst)
                 * 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);
index b5c50be10cc3ac7ab3d8cca825f4a943d635bc99..1f585d98f26e8e620bb4a6ed604578fca18c4b1b 100644 (file)
@@ -148,10 +148,14 @@ int mailbox_put(struct mailbox*, void*);
  *  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