Is the tevent tutorial correct?

Richard Sharpe realrichardsharpe at gmail.com
Thu Jan 22 09:58:55 MST 2015


On Thu, Jan 22, 2015 at 7:59 AM, Ralph Böhme <rb at sernet.de> wrote:
> On Thu, Jan 22, 2015 at 07:37:39AM -0800, Richard Sharpe wrote:
>> On Wed, Jan 21, 2015 at 11:07 PM, Ralph Böhme <rb at sernet.de> wrote:
>> > Hi Richard
>> >
>> > On Wed, Jan 21, 2015 at 06:41:28AM -0800, Richard Sharpe wrote:
>> >> On Wed, Jan 21, 2015 at 6:38 AM, Andreas Schneider <asn at samba.org> wrote:
>> >> > On Tuesday 20 January 2015 20:48:28 Richard Sharpe wrote:
>> >> >> Hi folks,
>> >> >>
>> >> >> I was reading this page https://tevent.samba.org/tevent_data.html
>> >> >> prior to taking some people through this tomorrow, and I extracted the
>> >> >> code in the tutorial and ran it.
>> >> >>
>> >> >> The tutorial claims I should see this:
>> >> >> ----------
>> >> >> a->x: 9
>> >> >> b->y: 10
>> >> >> c->y: 10
>> >> >> ----------
>> >> >>
>> >> >> However, I see this:
>> >> >>
>> >> >> ---------------
>> >> >> _send
>> >> >> a->x: 10
>> >> >> b->y: 9
>> >> >> c->y: 9
>> >> >> Quit
>> >> >> ---------------
>> >> >
>> >> > Might be a typo in the tutorial. Great that someone looks into it.
>> >> > Improvements are very welcome!
>> >>
>> >> I am also trying to understand the intent. The comments suggest that
>> >> the three numbers are pulled from different instances of the state
>> >> variables but that does not seem to be the case.
>> >
>> >   Private data can be of 2 types: connected with a request itself or
>> >   given as an individual argument to a callback. It is necessary to
>> >   differentiate these types, because there is a slightly different
>> >   method of data access for each. There are two possibilities how to
>> >   access data that is given as an argument directly to a callback.
>> >
>> > There are two types where one type has two access possibilites, makes
>> > for three possibilities.
>> >
>> > Patch for the wrong exmaple output attached. Please review and push if
>> > ok.
>>
>> Ahhh, I didn't see your patch when I constructed mine this morning.
>>
>> However, I think there is still one thing wrong with the example from
>> a pedagogic point of view, which is that by setting up the value of
>> the data passed in from main to be the same value as that set in a
>> later function it creates confusion is someone's mind, perhaps mine.
>
> Mine too! ;)
>
>> There is also a white-space issue in the top-most call back. See my
>> patch from today which is essentially yours with a few more changes.
>
> I saw your patch and had a few issues with it, I'll take another look.

OK, great. We can probably converge on something that is relatively
more easy to understand.

I think the confusion that has existed in my mind is that there are
two paradigms being mixed together. One is the event-based mechanism
where callbacks are not called from the context of the function that
creates the event and adds iit (eg, tevent_add_fd) and the other is
where a callback is executed directly (it seems to me) in the context
of the caller of a function like tevent_req_done.

However, perhaps I have got the wrong end of the stick. (That is an
English idiom that might not translate well. :-)

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list