From: Stefan Reinauer Date: Fri, 5 Jun 2026 04:41:33 +0000 (-0700) Subject: bsdsocket: preserve Unix trap context for host calls X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=d2482174dd91d2243a1a38781c11c4ceeb441bbb;p=francis%2Fwinuae.git bsdsocket: preserve Unix trap context for host calls The Unix shutdown and setsockopt paths need the active TrapContext when they resolve guest socket descriptors and copy guest option data. Store the current context in the socket base before dispatching those host calls and when the deferred WaitSelect worker is armed. --- diff --git a/bsdsocket.cpp b/bsdsocket.cpp index f68e9145..641a2fc4 100644 --- a/bsdsocket.cpp +++ b/bsdsocket.cpp @@ -639,6 +639,9 @@ static uae_u32 REGPARAM2 bsdsocklib_recv (TrapContext *ctx) static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *ctx) { struct socketbase *sb = get_socketbase (ctx); +#ifndef _WIN32 + sb->context = ctx; +#endif return host_shutdown (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } @@ -646,6 +649,9 @@ static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *ctx) static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *ctx) { struct socketbase *sb = get_socketbase (ctx); +#ifndef _WIN32 + sb->context = ctx; +#endif host_setsockopt (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 3)); return sb->resultval; diff --git a/od-unix/bsdsock_unix.cpp b/od-unix/bsdsock_unix.cpp index b5d53757..4682bcc6 100644 --- a/od-unix/bsdsock_unix.cpp +++ b/od-unix/bsdsock_unix.cpp @@ -1853,7 +1853,7 @@ void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8 *hmsg, uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how) { - TrapContext *ctx = NULL; + TrapContext *ctx = sb->context; SOCKET s; write_log("shutdown(%d,%d) -> ", sd, how); @@ -1874,7 +1874,7 @@ uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how) void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 len) { - TrapContext* ctx = NULL; + TrapContext* ctx = sb->context; int s = getsock(ctx, sb, sd + 1); void* buf = NULL; struct linger sl; @@ -2405,6 +2405,7 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3 sb->sets [2] = exceptfds; sb->timeout = timeout; sb->sigmp = wssigs; + sb->context = ctx; sb->action = 5; uae_sem_post (&sb->sem);