int Server_WorkerThread(void *ClientPtr)
{
tClient *Client = ClientPtr;
-
+
+ Log_Debug("Server", "Worker %p", ClientPtr);
+
#if USE_TCP
+
+ while( *((volatile typeof(Client->Socket)*)&Client->Socket) == 0 )
+ SDL_Delay(10);
+ Threads_SetThread( Client->ClientID );
+
for( ;; )
{
fd_set fds;
FD_SET(Client->Socket, &fds);
int rv = select(nfd, &fds, NULL, NULL, NULL); // TODO: Timeouts?
- if(rv <= 0) {
+ if(rv < 0) {
perror("select");
continue ;
}
-
+ Log_Debug("Server", "%p: rv=%i", Client, rv);
+
if( FD_ISSET(Client->Socket, &fds) )
{
const int ciMaxParamCount = 6;
free( retHeader );
}
#endif
+ Log_Notice("Server", "Terminated Worker %p", ClientPtr);
+ return 0;
}
int SyscallServer(void)
client->Socket = clientSock;
}
}
- Log_Debug("Server", "Client given PID %i", authhdr.pid);
+ Log_Debug("Server", "Client given PID %i - info %p", authhdr.pid, client);
len = send(clientSock, &authhdr, sizeof(authhdr), 0);
if( len != sizeof(authhdr) ) {
ret->ThreadName = strdup(TemplateThread->ThreadName);
ret->EventSem = SDL_CreateSemaphore(0);
+ if( !ret->EventSem ) {
+ Log_Warning("Threads", "Semaphore creation failed - %s", SDL_GetError());
+ }
ret->WaitingThreads = NULL;
ret->WaitingThreadsEnd = NULL;
gpCurrentThread->WaitMask = Mask;
if( !(gpCurrentThread->Events & Mask) )
{
- SDL_SemWait( gpCurrentThread->EventSem );
+ do {
+ if( SDL_SemWait( gpCurrentThread->EventSem ) == -1 ) {
+ Log_Warning("Threads", "Wait on eventsem of %p, %p failed",
+ gpCurrentThread, gpCurrentThread->EventSem);
+ break;
+ }
+ } while(SDL_SemValue(gpCurrentThread->EventSem));
+ // NOTE: While loop catches multiple event occurances
+ Log_Debug("Threads", "Woken from nap (%i here)", SDL_SemValue(gpCurrentThread->EventSem));
}
rv = gpCurrentThread->Events & Mask;
gpCurrentThread->Events &= ~Mask;
gpCurrentThread->WaitMask = -1;
-
+
+ Log_Debug("Threads", "- rv = %x", rv);
+
return rv;
}
// === CONSTANTS ===
#define NATIVE_FILE_MASK 0x40000000
+// === GLOBALS ===
+int acess__errno;
+
// === CODE ===
// --- VFS Calls
int acess_chdir(const char *Path)
// === Symbol List ===
-#define DEFSYM(name) {#name, acess_##name}
+#define DEFSYM(name) {#name, &acess_##name}
const tSym caBuiltinSymbols[] = {
DEFSYM(_exit),
DEFSYM(_SysAllocate),
DEFSYM(_SysDebug),
DEFSYM(_SysSetFaultHandler),
- DEFSYM(_SysWaitEvent)
+ DEFSYM(_SysWaitEvent),
+
+ DEFSYM(_errno)
};
const int ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]);
-#PREFIX := x86_64-pc-elf
-PREFIX := x86_64-none-elf
+PREFIX := x86_64-pc-elf
+#PREFIX := x86_64-none-elf
CC := $(PREFIX)-gcc
LD := $(PREFIX)-ld