Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / ipc_acess.c
index 1d6e344..700b60f 100644 (file)
 #include <string.h>
 
 // === CONSTANTS ===
-#define STATICBUF_SIZE 64
+#define STATICBUF_SIZE 256
 #define AXWIN_PORT     4101
 
 // === PROTOTYPES ===
 void   IPC_Init(void);
-void   IPC_FillSelect(int *nfds, fd_set *set);
-void   IPC_HandleSelect(fd_set *set);
+void   IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set);
+void   IPC_HandleSelect(fd_set *set, fd_set *err_set);
  int   IPC_Type_Datagram_GetSize(const void *Ident);
  int   IPC_Type_Datagram_Compare(const void *Ident1, const void *Ident2);
 void   IPC_Type_Datagram_Send(const void *Ident, size_t Length, const void *Data);
@@ -75,18 +75,20 @@ void _setfd(int fd, int *nfds, fd_set *set)
        }
 }
 
-void IPC_FillSelect(int *nfds, fd_set *set)
+void IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set)
 {
        _setfd(giNetworkFileHandle, nfds, set);
        _setfd(giIPCPipeHandle, nfds, set);
        for( int i = 0; i < giIPC_ClientCount; i ++ )
        {
-               if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe )
+               if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe ) {
                        _setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, set );
+                       _setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, err_set );
+               }
        }
 }
 
-void IPC_HandleSelect(fd_set *set)
+void IPC_HandleSelect(fd_set *set, fd_set *err_set)
 {
        if( giNetworkFileHandle != -1 && FD_ISSET(giNetworkFileHandle, set) )
        {
@@ -127,6 +129,12 @@ void IPC_HandleSelect(fd_set *set)
                                }
                                IPC_Handle( gIPC_Clients[i], len, (void*)staticBuf );
                        }
+                       if( FD_ISSET(fd, err_set) )
+                       {
+                               // Client disconnected
+                               IPC_int_DropClient(gIPC_Clients[i]);
+                               _SysClose(fd);
+                       }
                }
        }
 
@@ -190,8 +198,10 @@ int IPC_Type_IPCPipe_Compare(const void *Ident1, const void *Ident2)
 }
 void IPC_Type_IPCPipe_Send(const void *Ident, size_t Length, const void *Data)
 {
-       size_t rv = _SysWrite( *(const int*)Ident, Data, Length );
+        int    fd = *(const int*)Ident;
+       size_t rv = _SysWrite( fd, Data, Length );
        if(rv != Length) {
-               _SysDebug("Sent message oversize %x", Length);
+               _SysDebug("Message send for IPCPipe FD %i %i req, %i sent",
+                       fd, Length, rv);
        }
 }

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