[Spice-devel] [PATCH 3/5] worker: use GOnce to surround some global init in dispatcher
Jonathon Jongsma
jjongsma at redhat.com
Fri Oct 16 12:37:35 PDT 2015
On Fri, 2015-10-16 at 07:13 -0400, Frediano Ziglio wrote:
> >
> > From: Marc-André Lureau <marcandre.lureau at gmail.com>
> >
> > ---
> > server/red_dispatcher.c | 10 +++++++---
> > server/spice_server_utils.h | 1 +
> > 2 files changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
> > index b11cd42..7ad860c 100644
> > --- a/server/red_dispatcher.c
> > +++ b/server/red_dispatcher.c
> > @@ -1076,11 +1076,15 @@ void red_dispatcher_init(QXLInstance *qxl)
> >
> > spice_return_if_fail(qxl->st->dispatcher == NULL);
> >
> > - quic_init();
> > - sw_canvas_init();
> > + static gsize initialized = FALSE;
> > + if (g_once_init_enter(&initialized)) {
> > + quic_init();
> > + sw_canvas_init();
> > #ifdef USE_OPENGL
> > - gl_canvas_init();
> > + gl_canvas_init();
> > #endif // USE_OPENGL
> > + g_once_init_leave(&initialized, TRUE);
> > + }
> >
>
> In each of these functions there is a similar test.
> I'll ditch the patch entirely.
I guess the difference is that g_once_* is thread-safe. Unfortunately,
the commit log is very terse and doesn't indicate whether the patch was
in response to a specific bug that was encountered, or provide any
other justification for the change. Marc-Andre, do you remember?
In any case, I don't think there are really any drawbacks to the patch.
>
> > red_dispatcher = spice_new0(RedDispatcher, 1);
> > ring_init(&red_dispatcher->async_commands);
> > diff --git a/server/spice_server_utils.h
> > b/server/spice_server_utils.h
> > index b3ddc27..c8135db 100644
> > --- a/server/spice_server_utils.h
> > +++ b/server/spice_server_utils.h
> > @@ -2,6 +2,7 @@
> > #define H_SPICE_SERVER_UTIL
> >
> > #include <unistd.h>
> > +#include <glib.h>
> >
> > static inline void set_bit(int index, uint32_t *addr)
> > {
>
> Frediano
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list