[PATCH] tevent glib event loop glue
Jeremy Allison
jra at samba.org
Tue Feb 23 00:24:52 UTC 2016
On Mon, Feb 22, 2016 at 07:19:36PM +0000, Noel Power wrote:
> Well, I'd like to ask we hold off committing this (at least until the
> attached patches are evaluated), I've discovered an issue that leads me
> to believe that the current implementation wont work. I've come to the
> conclusion that actually going back to the idea of using trace callbacks
> is probably the only viable solution. The main problem with the current
> solution is that if any glib event sources are modified/created/deleted
> in the context of a tevent handler that isn't associated with the
> integration implementation then we don't pick up any of those changes
> (see first patch that modifies the client for a reproducer) This problem
Can you explain this a little better please ?
The patch seems to defer processing the callback
by interposing an immediate event.
What is the purpose of that ? What use case does
this test ?
Cheers,
Jeremy.
> From c5c92be0ae4dde3f5d09c348f9b20e6ce336869e Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at suse.com>
> Date: Mon, 22 Feb 2016 19:17:59 +0000
> Subject: [PATCH 1/2] Adjust test client to create activity in glib event
> sources from tevent context
>
> Glib event sources when created/deleted/modified via code called from
> a tevent event loop handler should be detected and processed.
> If glib_prepare is NOT called after such a tevent handler as described
> previously has fired then the affected glib event sources will not be
> monitored by tevent, consequently those glib event sources with ready
> events will not be dispatched.
> ---
> source3/utils/async-tracker.c | 45 ++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/source3/utils/async-tracker.c b/source3/utils/async-tracker.c
> index 4b674af..14134d0 100644
> --- a/source3/utils/async-tracker.c
> +++ b/source3/utils/async-tracker.c
> @@ -159,6 +159,21 @@ static void query_cb(GObject *object,
> }
> }
>
> +static void query_im_handler(struct tevent_context *ev,
> + struct tevent_immediate *im,
> + void *private_data)
> +{
> + struct test_state *state = talloc_get_type_abort(private_data, struct test_state);
> + tracker_sparql_connection_query_async(
> + state->connection,
> + "SELECT ?name nie:mimeType(?s) nfo:fileName(?s) "
> + "WHERE { {?s nie:url ?name}}",
> + state->cancellable,
> + query_cb,
> + state);
> + TALLOC_FREE(im);
> +}
> +
> static void connection_cb(GObject *object,
> GAsyncResult *res,
> gpointer user_data)
> @@ -174,13 +189,29 @@ static void connection_cb(GObject *object,
> g_timer_start(state->timer);
>
> if (!error) {
> - tracker_sparql_connection_query_async(
> - state->connection,
> - "SELECT ?name nie:mimeType(?s) nfo:fileName(?s) "
> - "WHERE { {?s nie:url ?name}}",
> - state->cancellable,
> - query_cb,
> - state);
> + if (state->loop_type == TEVENT_LOOP) {
> + /*
> + * set up query to run in the context of a
> + * tevent 'event'
> + */
> + struct tevent_immediate *im =
> + tevent_create_immediate(state);;
> + if (im == NULL) {
> + g_critical("Could not create immediate event");
> + cleanup(state);
> + }
> + tevent_schedule_immediate(im, state->ev,
> + query_im_handler,
> + state);
> + } else {
> + tracker_sparql_connection_query_async(
> + state->connection,
> + "SELECT ?name nie:mimeType(?s) nfo:fileName(?s) "
> + "WHERE { {?s nie:url ?name}}",
> + state->cancellable,
> + query_cb,
> + state);
> + }
> } else {
> g_critical("Could not connect: %s", error->message);
> g_error_free(error);
> --
> 2.1.4
>
More information about the samba-technical
mailing list