]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - linux/src/api/Ipc.c
MessageQ: Fix MessageQ_get() dropping messages
[ipc/ipcdev.git] / linux / src / api / Ipc.c
index d91be3e2f3fd07fc0c83254147376de31195a608..46db4ae16507a9f3176753d6bba30e4b3a484979 100644 (file)
@@ -44,9 +44,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
-#include <Std.h>
 
 /* Common IPC headers: */
+#include <ti/ipc/Std.h>
 #include <ti/ipc/Ipc.h>
 #include <ti/ipc/NameServer.h>
 
@@ -58,6 +58,8 @@
 #include <_MessageQ.h>
 #include <_NameServer.h>
 
+MultiProc_Config _MultiProc_cfg;
+
 static LAD_ClientHandle ladHandle;
 
 static void cleanup(int arg);
@@ -70,9 +72,11 @@ static void cleanup(int arg);
 Int Ipc_start (Void)
 {
     MessageQ_Config   msgqCfg;
-    Int32             status = Ipc_S_SUCCESS;
+    MultiProc_Config  mpCfg;
+    Int32             status;
     LAD_Status        ladStatus;
     UInt16            rprocId;
+    Int32             attachedAny = 0;
 
     /* Catch ctrl-C, and cleanup: */
     (void) signal(SIGINT, cleanup);
@@ -84,25 +88,38 @@ Int Ipc_start (Void)
         goto exit;
     }
 
+    /* Setup and get MultiProc configuration from LAD */
+    MultiProc_getConfig(&mpCfg);
+    _MultiProc_cfg = mpCfg;
+
     status = NameServer_setup();
     if (status >= 0) {
         MessageQ_getConfig(&msgqCfg);
         MessageQ_setup(&msgqCfg);
 
         /* Now attach to all remote processors, assuming they are up. */
-        for (rprocId = 0;
-             (rprocId < MultiProc_getNumProcessors()) && (status >= 0);
-             rprocId++) {
-           if (0 == rprocId) {
-               /* Skip host, which should always be 0th entry. */
-               continue;
-           }
-           status = MessageQ_attach (rprocId, NULL);
-           if (status < 0) {
-              printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
-                     rprocId, status);
-              status = Ipc_E_FAIL;
-           }
+        for (rprocId = 0; rprocId < MultiProc_getNumProcessors(); rprocId++) {
+            if (0 == rprocId) {
+                /* Skip host, which should always be 0th entry. */
+                continue;
+            }
+            status = MessageQ_attach(rprocId, NULL);
+            if (status == MessageQ_E_RESOURCE) {
+                continue;
+            }
+            if (status < 0) {
+                printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
+                       rprocId, status);
+                status = Ipc_E_FAIL;
+
+                break;
+            }
+            else {
+                attachedAny = 1;
+            }
+        }
+        if (attachedAny) {
+            status = Ipc_S_SUCCESS;
         }
     }
     else {