Usermode/AxWin3 - Debugging user reception of messages
authorJohn Hodge <[email protected]>
Tue, 8 Nov 2011 06:35:11 +0000 (14:35 +0800)
committerJohn Hodge <[email protected]>
Tue, 8 Nov 2011 06:35:11 +0000 (14:35 +0800)
Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c

index 2432fd8..3c7d109 100644 (file)
@@ -8,6 +8,7 @@
 #include <axwin3/axwin.h>
 #include "include/internal.h"
 #include "include/ipc.h"
+#include <stdlib.h>
 
 // === CODE ===
 int SoMain(void *Base, int argc, const char *argv[], const char **envp)
@@ -25,8 +26,13 @@ void AxWin3_MainLoop(void)
        while(!bExit)
        {
                msg = AxWin3_int_GetIPCMessage();
-               
+               if(!msg)        continue;       
+       
                // TODO: Handle message
+               _SysDebug("oh look, a message (Type=%i, Window=%i, Len=%i)",
+                       msg->ID, msg->Window, msg->Size);
+               
+               free(msg);
        }
 }
 
index c3c6be7..3b6a3ba 100644 (file)
@@ -129,6 +129,7 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
                        // Check if the message came from the server
                        if(tid != giConnectionNum)
                        {
+                               _SysDebug("%i byte message from %i", len, tid);
                                // If not, pass the buck (or ignore)
                                if( gAxWin3_MessageCallback )
                                        gAxWin3_MessageCallback(tid, len);
@@ -139,7 +140,11 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
                        
                        // If it's from the server, allocate a buffer and return it
                        ret = malloc(len);
-                       if(ret == NULL) return NULL;
+                       if(ret == NULL) {
+                               _SysDebug("malloc() failed, ignoring message");
+                               SysGetMessage(NULL, GETMSG_IGNORE);
+                               return NULL;
+                       }
                        SysGetMessage(NULL, ret);
                        break;
                }

UCC git Repository :: git.ucc.asn.au