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.
This commit is contained in:
pooka 2011-01-22 13:41:22 +00:00
parent 0feb91da5d
commit 1d9f8678bd
4 changed files with 28 additions and 10 deletions

View File

@ -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 @@ serv_handlesyscall(struct spclient *spc, struct rsp_hdr *rhdr, uint8_t *data)
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 @@ rumpuser_sp_init(const char *url, const struct rumpuser_sp_ops *spopsp,
}
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);

View File

@ -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 @@ struct spclient {
size_t spc_off;
uint64_t spc_nextreq;
uint64_t spc_syscallreq;
int spc_ostatus, spc_istatus;
LIST_HEAD(, prefork) spc_pflist;

View File

@ -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_copyout(void *, const void *, void *, size_t);
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_ */

View File

@ -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 @@ void
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) {