On Mon, Sep 9, 2013 at 10:22 PM, Yonit Halperin <yhalperi@xxxxxxxxxx> wrote: > ack. > > Notice that basically handle_msg of all the channels does the same, expect > it uses different msg handlers. It would have been cleaner to use one > handle_msg routine, and different msg handlers. Then, instead of checking > disable_channel_msg for each msg, we could just set the msg_handlers to NULL > (except for the base types). > You don't have to do it for this series. Your call. ok, I admit it has been a while I meant to improve this a little bit, see the updated series. > > On 09/08/2013 02:59 PM, Marc-André Lureau wrote: >> >> Allow to disable selectively channels, mainly used for testing, >> ex: SPICE_DISABLE_CHANNELS=display spicy-stats -p 12345 >> --- >> gtk/channel-display.c | 4 ++-- >> gtk/spice-channel-priv.h | 2 ++ >> gtk/spice-channel.c | 14 ++++++++++++-- >> 3 files changed, 16 insertions(+), 4 deletions(-) >> >> diff --git a/gtk/channel-display.c b/gtk/channel-display.c >> index 704d5a7..eab1742 100644 >> --- a/gtk/channel-display.c >> +++ b/gtk/channel-display.c >> @@ -1889,9 +1889,9 @@ static void spice_display_handle_msg(SpiceChannel >> *channel, SpiceMsgIn *msg) >> >> parent_class = >> SPICE_CHANNEL_CLASS(spice_display_channel_parent_class); >> >> - if (display_handlers[type] != NULL) >> + if (display_handlers[type] != NULL) { >> display_handlers[type](channel, msg); >> - else if (parent_class->handle_msg) >> + } else if (parent_class->handle_msg) >> parent_class->handle_msg(channel, msg); >> else >> g_return_if_reached(); >> diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h >> index be061c5..9e70ff2 100644 >> --- a/gtk/spice-channel-priv.h >> +++ b/gtk/spice-channel-priv.h >> @@ -134,6 +134,8 @@ struct _SpiceChannelPrivate { >> gsize total_read_bytes; >> uint64_t last_message_serial; >> GSList *flushing; >> + >> + gboolean disable_channel_msg; >> }; >> >> SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel); >> diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c >> index 093b292..778a90b 100644 >> --- a/gtk/spice-channel.c >> +++ b/gtk/spice-channel.c >> @@ -126,6 +126,10 @@ static void spice_channel_constructed(GObject >> *gobject) >> desc ? desc : "unknown", c->channel_type, c->channel_id); >> CHANNEL_DEBUG(channel, "%s", __FUNCTION__); >> >> + const char *disabled = g_getenv("SPICE_DISABLE_CHANNELS"); >> + if (disabled && strstr(disabled, desc)) >> + c->disable_channel_msg = TRUE; >> + >> c->connection_id = spice_session_get_connection_id(c->session); >> spice_session_channel_new(c->session, channel); >> >> @@ -2075,10 +2079,13 @@ static void >> spice_channel_iterate_write(SpiceChannel *channel) >> static void spice_channel_iterate_read(SpiceChannel *channel) >> { >> SpiceChannelPrivate *c = channel->priv; >> + handler_msg_in handler; >> + >> g_return_if_fail(c->state != SPICE_CHANNEL_STATE_MIGRATING); >> >> - spice_channel_recv_msg(channel, >> - (handler_msg_in)SPICE_CHANNEL_GET_CLASS(channel)->handle_msg, >> NULL); >> + handler = (handler_msg_in) (c->disable_channel_msg ? >> + spice_channel_handle_msg : >> SPICE_CHANNEL_GET_CLASS(channel)->handle_msg); >> + spice_channel_recv_msg(channel, handler, NULL); >> } >> >> static gboolean wait_migration(gpointer data) >> @@ -2777,6 +2784,9 @@ static void spice_channel_handle_msg(SpiceChannel >> *channel, SpiceMsgIn *msg) >> { >> int type = spice_msg_in_type(msg); >> >> + if (type > SPICE_N_ELEMENTS(base_handlers) && >> channel->priv->disable_channel_msg) >> + return; >> + >> g_return_if_fail(type < SPICE_N_ELEMENTS(base_handlers)); >> g_return_if_fail(base_handlers[type] != NULL); >> >> > -- Marc-André Lureau _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel