]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
bsdsocket: preserve Unix trap context for host calls
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Fri, 5 Jun 2026 04:41:33 +0000 (21:41 -0700)
committerStefan <stefan.reinauer@coreboot.org>
Sun, 14 Jun 2026 04:50:59 +0000 (21:50 -0700)
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.

bsdsocket.cpp
od-unix/bsdsock_unix.cpp

index f68e9145ff9e815fb8e6d911eece9103f7e59851..641a2fc479bb2a95e005e567d838ae972a47d29e 100644 (file)
@@ -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;
index b5d537572976b384c3fc2b46ee1ae02d2cd12957..4682bcc6c09fe36cfa7365de327c88241d686918 100644 (file)
@@ -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);