Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src In case sys_reboot() was called by a remote client, put the ...



details:   https://anonhg.NetBSD.org/src/rev/a758561cbaa4
branches:  trunk
changeset: 761258:a758561cbaa4
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sat Jan 22 13:41:22 2011 +0000

description:
In case sys_reboot() was called by a remote client, put the response
in the socket before we shut down.  This way the response to the
syscall travels to the caller and they know things worked correctly
instead of having to just assume.

diffstat:

 lib/librumpuser/rumpuser_sp.c    |  17 ++++++++++++++---
 lib/librumpuser/sp_common.c      |   3 ++-
 sys/rump/include/rump/rumpuser.h |   6 +++---
 sys/rump/librump/rumpkern/rump.c |  12 +++++++++---
 4 files changed, 28 insertions(+), 10 deletions(-)

diffs (125 lines):

diff -r 31d68d7ae3ce -r a758561cbaa4 lib/librumpuser/rumpuser_sp.c
--- a/lib/librumpuser/rumpuser_sp.c     Sat Jan 22 13:13:46 2011 +0000
+++ b/lib/librumpuser/rumpuser_sp.c     Sat Jan 22 13:41:22 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_sp.c,v 1.36 2011/01/14 13:12:14 pooka Exp $  */
+/*      $NetBSD: rumpuser_sp.c,v 1.37 2011/01/22 13:41:22 pooka Exp $  */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.36 2011/01/14 13:12:14 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.37 2011/01/22 13:41:22 pooka Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -584,7 +584,9 @@
            sysnum, spc->spc_pid));
 
        lwproc_newlwp(spc->spc_pid);
+       spc->spc_syscallreq = rhdr->rsp_reqno;
        rv = rumpsyscall(sysnum, data, retval);
+       spc->spc_syscallreq = 0;
        lwproc_release();
 
        DPRINTF(("rump_sp: got return value %d & %d/%d\n",
@@ -1143,8 +1145,17 @@
 }
 
 void
-rumpuser_sp_fini()
+rumpuser_sp_fini(void *arg)
 {
+       struct spclient *spc = arg;
+       register_t retval[2] = {0, 0};
+
+       /*
+        * stuff response into the socket, since this process is just
+        * about to exit
+        */
+       if (spc && spc->spc_syscallreq)
+               send_syscall_resp(spc, spc->spc_syscallreq, 0, retval);
 
        if (spclist[0].spc_fd) {
                parsetab[cleanupidx].cleanup(cleanupsa);
diff -r 31d68d7ae3ce -r a758561cbaa4 lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c       Sat Jan 22 13:13:46 2011 +0000
+++ b/lib/librumpuser/sp_common.c       Sat Jan 22 13:41:22 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: sp_common.c,v 1.24 2011/01/14 13:12:14 pooka Exp $    */
+/*      $NetBSD: sp_common.c,v 1.25 2011/01/22 13:41:22 pooka Exp $    */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -176,6 +176,7 @@
        size_t spc_off;
 
        uint64_t spc_nextreq;
+       uint64_t spc_syscallreq;
        int spc_ostatus, spc_istatus;
 
        LIST_HEAD(, prefork) spc_pflist;
diff -r 31d68d7ae3ce -r a758561cbaa4 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h  Sat Jan 22 13:13:46 2011 +0000
+++ b/sys/rump/include/rump/rumpuser.h  Sat Jan 22 13:41:22 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.h,v 1.63 2011/01/14 13:11:08 pooka Exp $      */
+/*     $NetBSD: rumpuser.h,v 1.64 2011/01/22 13:41:22 pooka Exp $      */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -36,7 +36,7 @@
 #include <stdint.h>
 #endif
 
-#define RUMPUSER_VERSION 10
+#define RUMPUSER_VERSION 11
 int rumpuser_getversion(void);
 
 int rumpuser_daemonize_begin(void);
@@ -230,6 +230,6 @@
 int    rumpuser_sp_copyoutstr(void *, const void *, void *, size_t *);
 int    rumpuser_sp_anonmmap(void *, size_t, void **);
 int    rumpuser_sp_raise(void *, int);
-void   rumpuser_sp_fini(void);
+void   rumpuser_sp_fini(void *);
 
 #endif /* _RUMP_RUMPUSER_H_ */
diff -r 31d68d7ae3ce -r a758561cbaa4 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Sat Jan 22 13:13:46 2011 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Sat Jan 22 13:41:22 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.219 2011/01/12 12:51:21 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.220 2011/01/22 13:41:22 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.219 2011/01/12 12:51:21 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.220 2011/01/22 13:41:22 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -498,9 +498,15 @@
 cpu_reboot(int howto, char *bootstr)
 {
        int ruhow = 0;
+       void *finiarg;
 
        printf("rump kernel halting...\n");
-       rumpuser_sp_fini();
+
+       if (!RUMP_LOCALPROC_P(curproc))
+               finiarg = curproc->p_vmspace->vm_map.pmap;
+       else
+               finiarg = NULL;
+       rumpuser_sp_fini(finiarg);
 
        /* dump means we really take the dive here */
        if ((howto & RB_DUMP) || panicstr) {



Home | Main Index | Thread Index | Old Index