Fixed Accept blocking when restarting toolbox with API running.
This commit is contained in:
+2
-1
@@ -360,4 +360,5 @@ MigrationBackup/
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
FodyWeavers.xsd
|
||||
/Playstation/Build/pkg/Orbis Toolbox/sflash0
|
||||
|
||||
Binary file not shown.
@@ -1,9 +1,13 @@
|
||||
#include "Common.h"
|
||||
#include "API.h"
|
||||
|
||||
Proc* API::Proc;
|
||||
Debug* API::Debug;
|
||||
Target* API::Target;
|
||||
SocketListener* API::Listener;
|
||||
|
||||
void API::ListenerCallback(void* tdParam, OrbisNetId s)
|
||||
{
|
||||
auto API = (class API*)tdParam;
|
||||
auto Packet = RecievePacket<APIPacket>(s);
|
||||
|
||||
if (Packet != nullptr)
|
||||
@@ -26,11 +30,11 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s)
|
||||
break;
|
||||
|
||||
case APICommands::PROC_START ... APICommands::PROC_END:
|
||||
API->Proc->HandleAPI(s, Packet);
|
||||
Proc->HandleAPI(s, Packet);
|
||||
break;
|
||||
|
||||
case APICommands::DBG_START ... APICommands::DBG_END:
|
||||
API->Debug->HandleAPI(s, Packet);
|
||||
Debug->HandleAPI(s, Packet);
|
||||
break;
|
||||
|
||||
case APICommands::KERN_START ... APICommands::KERN_END:
|
||||
@@ -39,7 +43,7 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s)
|
||||
break;
|
||||
|
||||
case APICommands::TARGET_START ... APICommands::TARGET_END:
|
||||
API->Target->HandleAPI(s, Packet);
|
||||
Target->HandleAPI(s, Packet);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -49,16 +53,16 @@ void API::ListenerCallback(void* tdParam, OrbisNetId s)
|
||||
free(Packet);
|
||||
}
|
||||
|
||||
API::API()
|
||||
void API::Init()
|
||||
{
|
||||
klog("API Startup.\n");
|
||||
Proc = new class Proc();
|
||||
Debug = new class Debug();
|
||||
Target = new class Target();
|
||||
Listener = new SocketListener(ListenerCallback, this, 6900);
|
||||
Listener = new SocketListener(ListenerCallback, NULL, 6900);
|
||||
}
|
||||
|
||||
API::~API()
|
||||
void API::Term()
|
||||
{
|
||||
delete Proc;
|
||||
delete Debug;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
class API
|
||||
{
|
||||
private:
|
||||
Proc* Proc;
|
||||
Debug* Debug;
|
||||
Target* Target;
|
||||
SocketListener* Listener;
|
||||
static Proc* Proc;
|
||||
static Debug* Debug;
|
||||
static Target* Target;
|
||||
static SocketListener* Listener;
|
||||
|
||||
static void ListenerCallback(void* tdParam, OrbisNetId s);
|
||||
|
||||
public:
|
||||
API();
|
||||
~API();
|
||||
static void Init();
|
||||
static void Term();
|
||||
};
|
||||
@@ -5,21 +5,10 @@
|
||||
void ReadFlash(off_t Offset, void* Data, unsigned int Size)
|
||||
{
|
||||
int fd = sceKernelOpen("/dev/sflash0", ORBIS_KERNEL_O_RDONLY, 0777);
|
||||
// int fd = sceKernelOpen("/data/Orbis Toolbox/sflash0", ORBIS_KERNEL_O_RDONLY, 0777);
|
||||
if (fd)
|
||||
{
|
||||
// For some reason I cant just read part of the flash. So all of it go brrr!
|
||||
auto Buffer = (unsigned char*)malloc(FLASH_BUF_LEN);
|
||||
memset(Buffer, 0, FLASH_BUF_LEN);
|
||||
|
||||
int bytesread = sceKernelRead(fd, Buffer, FLASH_BUF_LEN);
|
||||
|
||||
if (Offset + Size > bytesread)
|
||||
return;
|
||||
|
||||
// Copy the wanted data from the sflash.
|
||||
memcpy(Data, Buffer + Offset, Size);
|
||||
|
||||
free(Buffer);
|
||||
sceKernelPread(fd, Data, Size, Offset);
|
||||
sceKernelClose(fd);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Settings_Menu.h"
|
||||
#include "System_Monitor.h"
|
||||
#include "GamePad.h"
|
||||
#include "API.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -17,10 +18,14 @@ extern "C"
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Toolbox
|
||||
System_Monitor::Init();
|
||||
Settings_Menu::Init();
|
||||
//Title_Menu::Init();
|
||||
|
||||
// API
|
||||
API::Init();
|
||||
|
||||
Notify(ORBIS_TOOLBOX_NOTIFY);
|
||||
|
||||
return 0;
|
||||
@@ -30,10 +35,14 @@ extern "C"
|
||||
{
|
||||
klog("!! BYE !!\n");
|
||||
|
||||
// Toolbox
|
||||
Settings_Menu::Term();
|
||||
System_Monitor::Term();
|
||||
//Title_Menu::Term();
|
||||
|
||||
// API
|
||||
API::Term();
|
||||
|
||||
sceKernelSleep(4);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -42,56 +42,75 @@ void* SocketListener::DoWork()
|
||||
{
|
||||
klog("Failed to bind Listener to port %i\n", this->Port);
|
||||
|
||||
// Clean up.
|
||||
sceNetSocketClose(this->Socket);
|
||||
|
||||
// Kill our thread and exit.
|
||||
scePthreadExit(NULL);
|
||||
return nullptr;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (sceNetListen(this->Socket, 100) != 0)
|
||||
{
|
||||
klog("Failed to start listening on Socket.\n");
|
||||
|
||||
// Clean up.
|
||||
sceNetSocketClose(this->Socket);
|
||||
|
||||
// Kill our thread and exit.
|
||||
scePthreadExit(NULL);
|
||||
return nullptr;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
while (this->ServerRunning)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(this->Socket, &set); /* add our file descriptor to the set */
|
||||
|
||||
timeout.tv_sec = 2;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
// Wait fo rincoming connections.
|
||||
OrbisNetSockaddrIn ClientAddr = { 0 };
|
||||
OrbisNetSocklen_t addrlen = sizeof(OrbisNetSockaddrIn);
|
||||
auto ClientSocket = sceNetAccept(this->Socket, (OrbisNetSockaddr*)&ClientAddr, &addrlen);
|
||||
|
||||
if (ClientSocket != -1)
|
||||
auto rv = select((int)this->Socket + 1, &set, NULL, NULL, &timeout);
|
||||
if (rv == -1)
|
||||
goto Cleanup;
|
||||
else if (rv == 0)
|
||||
{
|
||||
//klog("New Connection from %i.%i.%i.%i!\n", ClientAddr.sin_addr.s_addr & 0xFF, (ClientAddr.sin_addr.s_addr >> 8) & 0xFF, (ClientAddr.sin_addr.s_addr >> 16) & 0xFF, (ClientAddr.sin_addr.s_addr >> 24) & 0xFF);
|
||||
|
||||
int optval = 1;
|
||||
sceNetSetsockopt(ClientSocket, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_NOSIGPIPE, &optval, sizeof(optval));
|
||||
// Set up thread params.
|
||||
ClientThreadParams* Params = new ClientThreadParams();
|
||||
Params->socketListener = this;
|
||||
Params->Sock = ClientSocket;
|
||||
|
||||
// Create Thread to handle connection.
|
||||
OrbisPthread* Thread;
|
||||
scePthreadCreate(&Thread, NULL, &ClientThread, Params, "Client Thread");
|
||||
|
||||
// Reset ClientSocket.
|
||||
ClientSocket = -1;
|
||||
if (!this->ServerRunning)
|
||||
goto Cleanup;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this->ServerRunning)
|
||||
goto Cleanup;
|
||||
|
||||
OrbisNetSockaddrIn ClientAddr = { 0 };
|
||||
OrbisNetSocklen_t addrlen = sizeof(OrbisNetSockaddrIn);
|
||||
auto ClientSocket = sceNetAccept(this->Socket, (OrbisNetSockaddr*)&ClientAddr, &addrlen);
|
||||
|
||||
if (ClientSocket != -1)
|
||||
{
|
||||
//klog("New Connection from %i.%i.%i.%i!\n", ClientAddr.sin_addr.s_addr & 0xFF, (ClientAddr.sin_addr.s_addr >> 8) & 0xFF, (ClientAddr.sin_addr.s_addr >> 16) & 0xFF, (ClientAddr.sin_addr.s_addr >> 24) & 0xFF);
|
||||
|
||||
int optval = 1;
|
||||
sceNetSetsockopt(ClientSocket, ORBIS_NET_SOL_SOCKET, ORBIS_NET_SO_NOSIGPIPE, &optval, sizeof(optval));
|
||||
// Set up thread params.
|
||||
ClientThreadParams* Params = new ClientThreadParams();
|
||||
Params->socketListener = this;
|
||||
Params->Sock = ClientSocket;
|
||||
|
||||
// Create Thread to handle connection.
|
||||
OrbisPthread* Thread;
|
||||
scePthreadCreate(&Thread, NULL, &ClientThread, Params, "Client Thread");
|
||||
|
||||
// Reset ClientSocket.
|
||||
ClientSocket = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
klog("Listener Thread Exiting!\n");
|
||||
|
||||
// Clean up.
|
||||
this->ThreadCleanedUp = true;
|
||||
|
||||
// Clean up.
|
||||
sceNetSocketClose(this->Socket);
|
||||
|
||||
// Kill our thread and exit.
|
||||
scePthreadExit(NULL);
|
||||
return nullptr;
|
||||
@@ -117,6 +136,10 @@ SocketListener::SocketListener(void(*ClientCallBack)(void* tdParam, OrbisNetId S
|
||||
|
||||
SocketListener::~SocketListener()
|
||||
{
|
||||
klog("~Socket Listener.\n");
|
||||
|
||||
this->ServerRunning = false;
|
||||
scePthreadCancel(*ListenThreadHandle);
|
||||
while (!this->ThreadCleanedUp) { sceKernelUsleep(10); }
|
||||
|
||||
klog("Destruction sucessful.\n");
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#define ORBIS_TOOLBOX_MAJOR 2
|
||||
#define ORBIS_TOOLBOX_MINOR 0
|
||||
#define ORBIS_TOOLBOX_BUILDVERSION 15
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
#if defined(ORBIS_TOOLBOX_DEBUG)
|
||||
#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Dev Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__)
|
||||
#else
|
||||
#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__)
|
||||
#endif
|
||||
#pragma once
|
||||
#define ORBIS_TOOLBOX_MAJOR 2
|
||||
#define ORBIS_TOOLBOX_MINOR 0
|
||||
#define ORBIS_TOOLBOX_BUILDVERSION 37
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
#if defined(ORBIS_TOOLBOX_DEBUG)
|
||||
#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Dev Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__)
|
||||
#else
|
||||
#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__)
|
||||
#endif
|
||||
|
||||
@@ -1 +1 @@
|
||||
958
|
||||
970
|
||||
|
||||
@@ -1 +1 @@
|
||||
Version 3.0.958 Debug Build Wednesday April 06 2022 9:32 PM
|
||||
Version 3.0.970 Debug Build Sunday April 10 2022 9:08 AM
|
||||
|
||||
Reference in New Issue
Block a user