Re: [PATCH] compatibility patch for event loop

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

 



On Mon, Feb 01, 2016 at 10:36:52AM +0000, Frediano Ziglio wrote:
> This patch use old code to implement timer events.
> The new version use some function from GLib 2.34 however some systems
> (like RHEL 6) have former GLib version (RHEL 6 has GLib 2.28 installed)
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/event-loop.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
> 
> diff --git a/server/event-loop.c b/server/event-loop.c
> index 6e08d78..9d51026 100644
> --- a/server/event-loop.c
> +++ b/server/event-loop.c
> @@ -24,6 +24,8 @@
>  
>  #include "red-common.h"
>  
> +#if GLIB_VERSION_CUR_STABLE >= GLIB_VERSION_2_34 \
> +    && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_34

This can be
#if GLIB_CHECK_VERSION(2, 34, 0)

>  struct SpiceTimer {
>      GSource source;
>  };
> @@ -72,6 +74,64 @@ static void timer_remove(SpiceTimer *timer)
>      g_source_destroy(&timer->source);
>      g_source_unref(&timer->source);
>  }
> +#else
> +struct SpiceTimer {
> +    GMainContext *context;
> +    SpiceTimerFunc func;
> +    void *opaque;
> +    GSource *source;
> +};
> +
> +static SpiceTimer* timer_add(const SpiceCoreInterfaceInternal *iface,
> +                             SpiceTimerFunc func, void *opaque)
> +{
> +    SpiceTimer *timer = spice_malloc0(sizeof(SpiceTimer));
> +
> +    timer->context = iface->main_context;
> +    timer->func = func;
> +    timer->opaque = opaque;
> +
> +    return timer;
> +}
> +
> +static gboolean timer_func(gpointer user_data)
> +{
> +    SpiceTimer *timer = user_data;
> +
> +    timer->func(timer->opaque);
> +    /* timer might be free after func(), don't touch */
> +
> +    return FALSE;
> +}
> +
> +static void timer_cancel(SpiceTimer *timer)
> +{
> +    if (timer->source) {
> +        g_source_destroy(timer->source);
> +        g_source_unref(timer->source);
> +        timer->source = NULL;
> +    }
> +}
> +
> +static void timer_start(SpiceTimer *timer, uint32_t ms)
> +{
> +    timer_cancel(timer);
> +
> +    timer->source = g_timeout_source_new(ms);
> +    spice_assert(timer->source != NULL);
> +
> +    g_source_set_callback(timer->source, timer_func, timer, NULL);
> +
> +    g_source_attach(timer->source, timer->context);
> +}
> +
> +static void timer_remove(SpiceTimer *timer)
> +{
> +    timer_cancel(timer);
> +    spice_assert(timer->source == NULL);
> +    free(timer);
> +}
> +#endif

Why not, though if we start having too many hacks like this, maybe it
will be best to give up on EL6 support in git master. In this case, an
alternative could be to revert the patch introducing the use of the new
glib functions.

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]