From: John Hodge Date: Wed, 3 Oct 2012 14:16:42 +0000 (+0800) Subject: AcessNative - Loads login process and runs again (shell doesn't spawn) X-Git-Tag: rel0.15~704 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9d2ff6cf13e1a0ec5cbdc2773e1a3204e600b2e5;p=tpg%2Facess2.git AcessNative - Loads login process and runs again (shell doesn't spawn) --- diff --git a/AcessNative/acesskernel_src/server.c b/AcessNative/acesskernel_src/server.c index 02aa290a..2f6b46fd 100644 --- a/AcessNative/acesskernel_src/server.c +++ b/AcessNative/acesskernel_src/server.c @@ -127,8 +127,15 @@ tClient *Server_GetClient(int ClientID) 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; @@ -137,11 +144,12 @@ int Server_WorkerThread(void *ClientPtr) 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; @@ -275,6 +283,8 @@ int Server_WorkerThread(void *ClientPtr) free( retHeader ); } #endif + Log_Notice("Server", "Terminated Worker %p", ClientPtr); + return 0; } int SyscallServer(void) @@ -386,7 +396,7 @@ int Server_ListenThread(void *Unused) 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) ) { diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index a7aace8b..c31c5d05 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -120,6 +120,9 @@ tThread *Threads_CloneTCB(tThread *TemplateThread) 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; @@ -373,12 +376,22 @@ Uint32 Threads_WaitEvents(Uint32 Mask) 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; } diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index fc336c8e..55606a8b 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -35,6 +35,9 @@ extern int AllocateMemory(uintptr_t VirtAddr, size_t ByteCount); // === CONSTANTS === #define NATIVE_FILE_MASK 0x40000000 +// === GLOBALS === +int acess__errno; + // === CODE === // --- VFS Calls int acess_chdir(const char *Path) @@ -303,7 +306,7 @@ void acess__exit(int Status) // === Symbol List === -#define DEFSYM(name) {#name, acess_##name} +#define DEFSYM(name) {#name, &acess_##name} const tSym caBuiltinSymbols[] = { DEFSYM(_exit), @@ -339,7 +342,9 @@ const tSym caBuiltinSymbols[] = { DEFSYM(_SysAllocate), DEFSYM(_SysDebug), DEFSYM(_SysSetFaultHandler), - DEFSYM(_SysWaitEvent) + DEFSYM(_SysWaitEvent), + + DEFSYM(_errno) }; const int ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]); diff --git a/BuildConf/x86_64/Makefile.cfg b/BuildConf/x86_64/Makefile.cfg index ebca2d9f..6aa3afc6 100644 --- a/BuildConf/x86_64/Makefile.cfg +++ b/BuildConf/x86_64/Makefile.cfg @@ -1,6 +1,6 @@ -#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