ret->Mutex = SDL_CreateMutex();
SDL_mutexP( ret->Mutex );
#endif
+ Log_Debug("Server", "Creating worker for %p", ret);
ret->WorkerThread = SDL_CreateThread( Server_WorkerThread, ret );
}
#if USE_TCP
while( *((volatile typeof(Client->Socket)*)&Client->Socket) == 0 )
- SDL_Delay(10);
+ ;
Threads_SetThread( Client->ClientID );
for( ;; )
// Allocate full buffer
hdr = malloc(bufsize);
memcpy(hdr, lbuf, hdrsize);
- len = recv(Client->Socket, hdr->Params + hdr->NParams, bufsize - hdrsize, 0);
- Log_Debug("Server", "%i bytes of data", len);
- if( len != bufsize - hdrsize ) {
- // Oops?
+ if( bufsize > hdrsize )
+ {
+ len = recv(Client->Socket, hdr->Params + hdr->NParams, bufsize - hdrsize, 0);
+ Log_Debug("Server", "%i bytes of data", len);
+ if( len != bufsize - hdrsize ) {
+ // Oops?
+ }
}
+ else
+ Log_Debug("Server", "no data");
int retlen;
tRequestHeader *retHeader;
char addrstr[4*8+8+1];
inet_ntop(clientaddr.sin_family, &clientaddr.sin_addr, addrstr, sizeof(addrstr));
- Log_Debug("Server", "Client connection %s:%i\n", addrstr, ntohs(clientaddr.sin_port));
+ Log_Debug("Server", "Client connection %s:%i", addrstr, ntohs(clientaddr.sin_port));
// Perform auth
size_t len;
// Some form of error?
Log_Warning("Server", "Client auth block bad size (%i != exp %i)",
len, sizeof(authhdr));
+ close(clientSock);
continue ;
}
// Get client structure and make sure it's unused
// - Auth token / verifcation?
client = Server_GetClient(authhdr.pid);
+ if( !client ) {
+ Log_Warning("Server", "Can't allocate a client struct for %s:%i",
+ addrstr, clientaddr.sin_port);
+ close(clientSock);
+ continue ;
+ }
if( client->Socket != 0 ) {
Log_Warning("Server", "Client (%i)%p owned by FD%i but %s:%i tried to use it",
authhdr.pid, client, addrstr, clientaddr.sin_port);
- authhdr.pid = 0;
+ close(clientSock);
+ continue;
}
else {
client->Socket = clientSock;
);
}
-int acess_readdir(int fd, char *dest) {
- DEBUG("readdir(%i, %p)", fd, dest);
+int acess_SysReadDir(int fd, char *dest) {
+ DEBUG("SysReadDir(%i, %p)", fd, dest);
return _Syscall(SYS_READDIR, ">i <d", fd, 256, dest);
}
if(ret == 0)
{
_CloseSyscalls();
- _InitSyscalls();
giSyscall_ClientID = newID;
+ _InitSyscalls();
return 0;
}
DEFSYM(tell),
DEFSYM(ioctl),
DEFSYM(finfo),
- DEFSYM(readdir),
+ DEFSYM(SysReadDir),
DEFSYM(select),
DEFSYM(_SysOpenChild),
DEFSYM(_SysGetACL),