From cf34bc4436187ab08c5c61baeb6d80276aa58c87 Mon Sep 17 00:00:00 2001 From: SirHumza <204067870+SirHumza@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:18:58 +0200 Subject: [PATCH] subagent audit fixes: unload-on-fail, progress reclaim, send timeout, gp4 prereqs --- installer/Makefile | 5 +---- installer/installer.c | 2 +- installer/send.c | 5 +++++ installer/ui.c | 24 ++++++++++++++++++++---- orbisrpc/daemon.c | 17 ++++++++++++----- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/installer/Makefile b/installer/Makefile index 811ad2a..407c12d 100644 --- a/installer/Makefile +++ b/installer/Makefile @@ -37,7 +37,7 @@ all: $(CONTENT_ID).pkg $(CONTENT_ID).pkg: installer/pkg.gp4 cd installer && $(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core pkg_build pkg.gp4 . && mv $(CONTENT_ID).pkg .. -installer/pkg.gp4: installer/eboot.bin installer/assets/daemon.elf installer/assets/evict.elf installer/sce_sys/about/right.sprx installer/sce_sys/param.sfo installer/sce_sys/icon0.png $(LIBMODULES) $(ASSETS) +installer/pkg.gp4: installer/eboot.bin installer/assets/daemon.elf installer/assets/evict.elf installer/sce_sys/about/right.sprx installer/sce_sys/param.sfo installer/sce_sys/icon0.png installer/sce_sys/pic1.png $(LIBMODULES) $(ASSETS) cd installer && $(TOOLCHAIN)/bin/$(CDIR)/create-gp4 -out pkg.gp4 --content-id=$(CONTENT_ID) --files "eboot.bin assets/daemon.elf assets/evict.elf sce_sys/about/right.sprx sce_sys/param.sfo sce_sys/icon0.png sce_sys/pic1.png sce_module/libSceFios2.prx sce_module/libc.prx $(patsubst installer/%,%,$(ASSETS))" installer/sce_sys/param.sfo: installer/Makefile @@ -68,9 +68,6 @@ installer/assets/daemon.elf: build-sdk/orbisrpc_sdk.elf cp $< $@ installer/assets/evict.elf: build-sdk/evict.elf cp $< $@ -# Brand logo placeholder (PS mark) until the ORBIS RPC art lands. -installer/assets/logo.png: config/icons/home.png - cp $< $@ $(INTDIR)/%.o: $(PROJDIR)/%.cpp $(CCX) $(CXXFLAGS) -o $@ $< diff --git a/installer/installer.c b/installer/installer.c index 6343af3..43a72c2 100644 --- a/installer/installer.c +++ b/installer/installer.c @@ -194,7 +194,7 @@ int main(void){ if(ui_init() != 0) return 1; q = ui_confirm("Install orbisRPC?\n\nCopies the daemon, sets up config, checks WiFi, saves your token, and starts it."); if(q != 1) return 0; - if(step_files() != 0) return 0; + if(step_files() != 0) return 1; step_wifi(); step_token(); step_inject(); diff --git a/installer/send.c b/installer/send.c index 8da5ef5..758bb57 100644 --- a/installer/send.c +++ b/installer/send.c @@ -108,6 +108,7 @@ int send_file_loopback(const char *path, int *port_used, void (*progress)(unsign for(i = 0; i < sizeof SEND_PORTS/sizeof SEND_PORTS[0]; i++){ int fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in sa; + struct timeval tv = { 20, 0 }; if(fd < 0) continue; memset(&sa, 0, sizeof sa); sa.sin_family = AF_INET; @@ -117,6 +118,10 @@ int send_file_loopback(const char *path, int *port_used, void (*progress)(unsign close(fd); continue; } + /* Back to blocking for the bulk send, WITH a send timeout so a + * stalled loader surfaces EAGAIN (capped retries below) instead + * of wedging forever. */ + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv); if(send_one(fd, path, progress) == 0){ close(fd); if(port_used) *port_used = SEND_PORTS[i]; diff --git a/installer/ui.c b/installer/ui.c index 7987338..a7f9ae1 100644 --- a/installer/ui.c +++ b/installer/ui.c @@ -36,9 +36,21 @@ int ui_init(void){ (void)sceUserServiceInitialize(&up); } if(sceSysmoduleLoadModule(ORBIS_SYSMODULE_MESSAGE_DIALOG) < 0) return -1; - if(sceSysmoduleLoadModule(ORBIS_SYSMODULE_IME_DIALOG) < 0) return -1; - if(sceSysmoduleLoadModule(ORBIS_SYSMODULE_IME_BACKEND) < 0) return -1; - if(sceCommonDialogInitialize() < 0) return -1; + if(sceSysmoduleLoadModule(ORBIS_SYSMODULE_IME_DIALOG) < 0){ + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_MESSAGE_DIALOG); + return -1; + } + if(sceSysmoduleLoadModule(ORBIS_SYSMODULE_IME_BACKEND) < 0){ + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_IME_DIALOG); + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_MESSAGE_DIALOG); + return -1; + } + if(sceCommonDialogInitialize() < 0){ + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_IME_BACKEND); + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_IME_DIALOG); + sceSysmoduleUnloadModule(ORBIS_SYSMODULE_MESSAGE_DIALOG); + return -1; + } ui_ready = 1; return 0; } @@ -86,7 +98,11 @@ static int progress_open = 0; int ui_progress_open(const char *msg){ OrbisMsgDialogParam param; OrbisMsgDialogProgressBarParam bar; - if(progress_open) return 0; + if(progress_open){ + /* Self-healing: a prior session that died between open and close + * leaves the flag set with no dialog behind it. Reclaim it. */ + ui_progress_close(); + } sceMsgDialogInitialize(); base_init(¶m); param.mode = ORBIS_MSG_DIALOG_MODE_PROGRESS_BAR; diff --git a/orbisrpc/daemon.c b/orbisrpc/daemon.c index fcf15b4..25bf846 100644 --- a/orbisrpc/daemon.c +++ b/orbisrpc/daemon.c @@ -299,6 +299,11 @@ int daemon_run(const char *fixed_game_name){ static char sess_tid[16] = ""; static int64_t started = 0; static int64_t last_tsync = 0; + static int home_posted = 0; + /* Fresh (re)connect invalidates whatever Discord shows: re-post the + * current state (game via need_post below, home via home_posted + * reset) so a drop can never leave a stale/blank tile behind. */ + home_posted = 0; /* Resume window: if the same title vanishes briefly (detection * flicker, quick menu hop) and returns within 10 minutes, the * timer resumes instead of resetting to 0:00. */ @@ -361,7 +366,6 @@ int daemon_run(const char *fixed_game_name){ static int cand_hits = 0, miss_hits = 0; int64_t last_poll = 0; int64_t last_alive = 0; - static int home_posted = 0; static int healthy_marked = 0; /* re-post after every (re)connect so Discord never sticks on stale */ int need_post = active && last[0]; @@ -531,11 +535,14 @@ int daemon_run(const char *fixed_game_name){ * more than a second or two late or the server drops us */ int tr = discord_tick(&dc); if(tr == -2){ - log_msg("FATAL: token rejected (close 4004). Fix %s", CFG_PATH); + /* Token rejected mid-session: same policy as connect-time + * 4004 (never strand the daemon). Drop to the outer loop: + * backoff + config reload picks up a fixed token alone. */ + log_msg("WARN: token rejected (close 4004). Fix %s; retrying", CFG_PATH); ws_close(&dc.ws); - health_mark_clean(); - log_close(); - return 2; + pres_set(&pres, PS_NONE); + if(sleep_stop(reconnect_delay(&conn_fails, base_poll, &jctr))) break; + break; } if(tr == -3){ int wait = reconnect_delay(&conn_fails, base_poll, &jctr);