Module Name: src Committed By: pooka Date: Thu Oct 28 14:37:29 UTC 2010
Modified Files: src/lib/librumpuser: rumpuser_sp.c Log Message: Run different clients (different sockets) in different processes inside the rump kernel. Now different host processes can no longer step on each other inside the rump kernel. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/librumpuser/rumpuser_sp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librumpuser/rumpuser_sp.c diff -u src/lib/librumpuser/rumpuser_sp.c:1.1 src/lib/librumpuser/rumpuser_sp.c:1.2 --- src/lib/librumpuser/rumpuser_sp.c:1.1 Wed Oct 27 20:44:50 2010 +++ src/lib/librumpuser/rumpuser_sp.c Thu Oct 28 14:37:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser_sp.c,v 1.1 2010/10/27 20:44:50 pooka Exp $ */ +/* $NetBSD: rumpuser_sp.c,v 1.2 2010/10/28 14:37:29 pooka Exp $ */ /* * Copyright (c) 2010 Antti Kantee. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: rumpuser_sp.c,v 1.1 2010/10/27 20:44:50 pooka Exp $"); +__RCSID("$NetBSD: rumpuser_sp.c,v 1.2 2010/10/28 14:37:29 pooka Exp $"); #include <sys/types.h> #include <sys/mman.h> @@ -121,6 +121,7 @@ struct spclient { int spc_fd; + struct lwp *spc_lwp; /* incoming */ struct rsp_hdr spc_hdr; @@ -312,13 +313,16 @@ } static void -serv_handle_disco(unsigned int idx) +serv_handledisco(unsigned int idx) { struct spclient *spc = &spclist[idx]; int fd = spc->spc_fd; DPRINTF(("rump_sp: disconnecting [%u]\n", idx)); + rump_pub_lwproc_switch(spc->spc_lwp); + rump_pub_lwproc_releaselwp(); + free(spc->spc_buf); memset(spc, 0, sizeof(*spc)); close(fd); @@ -369,10 +373,15 @@ return error; } + if ((error = rump_pub_lwproc_newproc()) != 0) { + close(newfd); + return error; + } + /* find empty slot the simple way */ for (i = 0; i < MAXCLI; i++) { if (pfdlist[i].fd == -1) - break; + break; } assert(i < MAXCLI); @@ -380,10 +389,14 @@ pfdlist[i].fd = newfd; spclist[i].spc_fd = newfd; + spclist[i].spc_lwp = rump_pub_lwproc_curlwp(); if (maxidx < i) maxidx = i; - DPRINTF(("rump_sp: added new connection at idx %u\n", i)); + DPRINTF(("rump_sp: added new connection at idx %u, pid %d\n", + i, rump_sys_getpid())); + + rump_pub_lwproc_switch(NULL); return 0; } @@ -399,7 +412,9 @@ sysnum, 0)); pthread_setspecific(spclient_tls, spc); + rump_pub_lwproc_switch(spc->spc_lwp); rv = rump_pub_syscall(sysnum, data, retval); + rump_pub_lwproc_switch(NULL); pthread_setspecific(spclient_tls, NULL); send_syscall_resp(spc, rhdr->rsp_reqno, rv, retval); @@ -812,7 +827,7 @@ case 0: break; case -1: - serv_handle_disco(idx); + serv_handledisco(idx); break; default: spc->spc_off = 0;