[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Jun 10 03:24:31 MDT 2010


The branch, master has been updated
       via  1819beb... s3: Add a dummy test to prove the maxfd calculation
       via  7f29f81... tevent: Fix maxfd calculation in tevent_select
      from  9fdb69e... s3-smbd: Fix typo in comment.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1819beb0887d7ee75318d330124c13b2ad2d830b
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 10 09:50:32 2010 +0200

    s3: Add a dummy test to prove the maxfd calculation
    
    To be run in a debugger, there's no way to inspect the internal tevent_select.c
    maxfd calculation

commit 7f29f817fa939ef1bbb740584f09e76e2ecd5b06
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 10 09:41:11 2010 +0200

    tevent: Fix maxfd calculation in tevent_select
    
    When doing
    
            fd1 = tevent_add_fd(ev, ev, 2, 0, NULL, NULL);
            fd2 = tevent_add_fd(ev, ev, 3, 0, NULL, NULL);
            TALLOC_FREE(fd2);
            fd2 = tevent_add_fd(ev, ev, 1, 0, NULL, NULL);
    
    we end up with select_ev->maxfd==1. This is wrong.
    
    An alternative fix might be to make select_ev->maxfd an unsigned int and make
    EVENT_INVALID_MAXFD==UINT_MAX. But in theory we might end up with an fd of
    UINT_MAX.
    
    std_event_add_fd() contains exactly the same piece of code, so I'm directly
    pushing it.
    
    Volker

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/tevent_select.c |    3 ++-
 source3/torture/torture.c  |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c
index 1598094..8cc6d06 100644
--- a/lib/tevent/tevent_select.c
+++ b/lib/tevent/tevent_select.c
@@ -116,7 +116,8 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
 				   handler_name, location);
 	if (!fde) return NULL;
 
-	if (fde->fd > select_ev->maxfd) {
+	if ((select_ev->maxfd != EVENT_INVALID_MAXFD)
+	    && (fde->fd > select_ev->maxfd)) {
 		select_ev->maxfd = fde->fd;
 	}
 	talloc_set_destructor(fde, select_event_fd_destructor);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 72b2296..696aaa3 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7335,6 +7335,48 @@ static bool run_local_dbtrans(int dummy)
 	return true;
 }
 
+/*
+ * Just a dummy test to be run under a debugger. There's no real way
+ * to inspect the tevent_select specific function from outside of
+ * tevent_select.c.
+ */
+
+static bool run_local_tevent_select(int dummy)
+{
+	struct tevent_context *ev;
+	struct tevent_fd *fd1, *fd2;
+	bool result = false;
+
+	ev = tevent_context_init_byname(NULL, "select");
+	if (ev == NULL) {
+		d_fprintf(stderr, "tevent_context_init_byname failed\n");
+		goto fail;
+	}
+
+	fd1 = tevent_add_fd(ev, ev, 2, 0, NULL, NULL);
+	if (fd1 == NULL) {
+		d_fprintf(stderr, "tevent_add_fd failed\n");
+		goto fail;
+	}
+	fd2 = tevent_add_fd(ev, ev, 3, 0, NULL, NULL);
+	if (fd2 == NULL) {
+		d_fprintf(stderr, "tevent_add_fd failed\n");
+		goto fail;
+	}
+	TALLOC_FREE(fd2);
+
+	fd2 = tevent_add_fd(ev, ev, 1, 0, NULL, NULL);
+	if (fd2 == NULL) {
+		d_fprintf(stderr, "tevent_add_fd failed\n");
+		goto fail;
+	}
+
+	result = true;
+fail:
+	TALLOC_FREE(ev);
+	return result;
+}
+
 static double create_procs(bool (*fn)(int), bool *result)
 {
 	int i, status;
@@ -7513,6 +7555,7 @@ static struct {
 	{ "LOCAL-WBCLIENT", run_local_wbclient, 0},
 	{ "LOCAL-string_to_sid", run_local_string_to_sid, 0},
 	{ "LOCAL-DBTRANS", run_local_dbtrans, 0},
+	{ "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},
 	{NULL, NULL, 0}};
 
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list