[Spice-devel] Help on terminate on disconnect feature needed
Alon Levy
alevy at redhat.com
Tue Aug 14 01:40:01 PDT 2012
On Mon, Aug 13, 2012 at 10:38:28AM -0500, Jeremy White wrote:
> On 08/12/2012 05:10 PM, Alon Levy wrote:
> > On Fri, Aug 10, 2012 at 03:57:05PM -0500, Jeremy White wrote:
> >> I've got a need for an Xspice feature whereby the whole X server dies on
> >> client disconnect. Basically, we want the Xspice session to live
> >> exactly once, and then die.
> >
> > You are talking about the spice client?
>
> Yes, right. Having a spice server have exactly one client and
> committing sepaku from grief if it's client vanishes :-/.
>
> >
> >>
> >> As I puzzle through the code, I don't have the feeling that there is an
> >> obvious place to inject that logic. I mean, I can shove an abort()
> >> pretty much anywhere. But I'd like to do it gracefully.
> >
> > Look at server/red_channel.c; there is a per channel on_disconnect
> > callback, you can add a parameter to it. Also, why abort, exit sounds
> > like what you want.
>
> Yes, definitely exit. Would a patch like this make sense?
Yes. But you also need to bump the server version (configure.ac) and the
symbols, i.e. something like the below.
--- a/configure.ac
+++ b/configure.ac
@@ -12,10 +12,10 @@ AC_PREREQ([2.57])
m4_define([SPICE_MAJOR], 0)
m4_define([SPICE_MINOR], 11)
-m4_define([SPICE_MICRO], 1)
-m4_define([SPICE_CURRENT], [3])
+m4_define([SPICE_MICRO], 2)
+m4_define([SPICE_CURRENT], [4])
m4_define([SPICE_REVISION], [0])
-m4_define([SPICE_AGE], [2])
+m4_define([SPICE_AGE], [3])
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -116,3 +116,7 @@ SPICE_SERVER_0.10.3 {
SPICE_SERVER_0.10.4 {
spice_qxl_monitors_config_async;
} SPICE_SERVER_0.10.3;
+
+SPICE_SERVER_0.11.1 {
+ spice_server_set_exit_on_disconnect;
+} SPICE_SERVER_0.10.4;
>
> Cheers,
>
> Jeremy
> diff --git a/server/reds.c b/server/reds.c
> index e3ea154..fab6114 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -118,6 +118,7 @@ void *red_tunnel = NULL;
> #endif
> int agent_mouse = TRUE;
> int agent_copypaste = TRUE;
> +static bool exit_on_disconnect = FALSE;
>
> #define MIGRATE_TIMEOUT (1000 * 10) /* 10sec */
> #define MM_TIMER_GRANULARITY_MS (1000 / 30)
> @@ -630,6 +631,12 @@ void reds_client_disconnect(RedClient *client)
> {
> RedsMigTargetClient *mig_client;
>
> + if (exit_on_disconnect)
> + {
> + spice_info("Exiting server because of client disconnect.\n");
> + exit(0);
> + }
> +
> if (!client || client->disconnecting) {
> return;
> }
> @@ -3570,6 +3577,13 @@ SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int lis
> return 0;
> }
>
> +SPICE_GNUC_VISIBLE int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag)
> +{
> + spice_assert(reds == s);
> + exit_on_disconnect = !!flag;
> + return 0;
> +}
> +
> SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)
> {
> spice_assert(reds == s);
> diff --git a/server/spice.h b/server/spice.h
> index 3d70ec7..30f4a8d 100644
> --- a/server/spice.h
> +++ b/server/spice.h
> @@ -425,6 +425,7 @@ int spice_server_set_compat_version(SpiceServer *s,
> int spice_server_set_port(SpiceServer *s, int port);
> void spice_server_set_addr(SpiceServer *s, const char *addr, int flags);
> int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd);
> +int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag);
> int spice_server_set_noauth(SpiceServer *s);
> int spice_server_set_sasl(SpiceServer *s, int enabled);
> int spice_server_set_sasl_appname(SpiceServer *s, const char *appname);
More information about the Spice-devel
mailing list