Is the tevent tutorial correct?

Ralph Böhme rb at sernet.de
Thu Jan 22 00:07:27 MST 2015


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.

-Ralph

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From dedf88110732f610b7c05d83283de8dd1a7f9a8d Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 21 Jan 2015 20:54:44 +0100
Subject: [PATCH] tevent:doc: fix tevent_data example

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tevent/doc/tevent_data.dox | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/tevent/doc/tevent_data.dox b/lib/tevent/doc/tevent_data.dox
index 4ee4ac2..8fea4f4 100644
--- a/lib/tevent/doc/tevent_data.dox
+++ b/lib/tevent/doc/tevent_data.dox
@@ -46,13 +46,13 @@ struct testA {
 
 
 static void foo_done(struct tevent_req *req) {
-// a->x contains 9
+// a->x contains 10
 struct foo_state *a = tevent_req_data(req, struct foo_state);
 
-// b->y contains 10
+// b->y contains 9
 struct testA *b = tevent_req_callback_data(req, struct testA);
 
-// c->y contains 10
+// c->y contains 9
 struct testA *c = (struct testA *)tevent_req_callback_data_void(req);
 
 printf("a->x: %d\n", a->x);
@@ -125,9 +125,9 @@ int main (int argc, char **argv) {
 Output of this example is:
 
 @code
-a->x: 9
-b->y: 10
-c->y: 10
+a->x: 10
+b->y: 9
+c->y: 9
 @endcode
 
 */
-- 
1.9.3



More information about the samba-technical mailing list