[SCM] Samba Shared Repository - branch v4-3-test updated

Karolin Seeger kseeger at samba.org
Thu Oct 20 12:07:04 UTC 2016


The branch, v4-3-test has been updated
       via  2017335 s3:libads: don't use MEMORY:ads_sasl_spnego_bind nor set "KRB5CCNAME"
       via  d4e019f s3:libads: don't use MEMORY:ads_sasl_gssapi_do_bind nor set "KRB5CCNAME"
       via  532fd56 HEIMDAL:lib/krb5: destroy a memory ccache on reinit
       via  cdc53e7 autobuild: Use cp --recursive --link --archive
       via  69ea4ba s3-printing: fix migrate printer code (bug 8618)
       via  8e2589e spoolss: Fix caching of printername->sharename
       via  af851c2 glusterfs: Avoid tevent_internal.h
       via  a992329 s3: events. Move events.c to util_event.c
       via  51cad54 s3: server: s3_tevent_context_init() -> samba_tevent_context_init()
       via  70edf8c s3: winbind: Remove dump_event_list() calls.
       via  0d0339b s3: nmbd: Final changeover to stock tevent for nmbd.
       via  4212718 s3: nmbd: Change over to using tevent functions from direct poll.
       via  6b134a8 s3: nmbd: Add a talloc_stackframe().
       via  928f281 s3: nmbd: Add (currently unused) timeout and fd handlers.
       via  9236d1cf s3: nmbd: Now attrs array mirrors fd's array use it in preference.
       via  0918f18 s3: nmbd: Ensure attrs array mirrors fd's array for dns.
       via  447b640 s3: nmbd: Add fd, triggered elements to struct socket_attributes.
       via  de63f7d s3:nmbd: fix talloc_zero_array() check in nmbd_packets.c
      from  2014c08 s3-spoolss: fix winreg_printer_ver_to_qword

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-3-test


- Log -----------------------------------------------------------------
commit 20173352cf707dc4fab8d4ae97d2fb90253242b9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 10 17:07:12 2016 +0200

    s3:libads: don't use MEMORY:ads_sasl_spnego_bind nor set "KRB5CCNAME"
    
    Most callers just set "KRB5CCNAME", but leave ads->auth.ccache_name = NULL.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12369
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Oct 13 00:35:21 CEST 2016 on sn-devel-144
    
    (cherry picked from commit a5f895a53016af71db53967062728fec5bc307ca)
    
    Autobuild-User(v4-3-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-3-test): Thu Oct 20 14:06:17 CEST 2016 on sn-devel-104

commit d4e019f42fa24cb9efc2d1463b5dbcaf7e752249
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 10 17:07:12 2016 +0200

    s3:libads: don't use MEMORY:ads_sasl_gssapi_do_bind nor set "KRB5CCNAME"
    
    Most callers just set "KRB5CCNAME", but leave ads->auth.ccache_name = NULL.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12369
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 890b1bbdb8e965c4ff6e35214acc96ffbbff5dfd)

commit 532fd56b3f16e72ea0f088f4cdfc03d23aa43435
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 10 15:53:26 2016 +0200

    HEIMDAL:lib/krb5: destroy a memory ccache on reinit
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12369
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 2abc3710a8a63327a769ba0482c553ed274b2113)

commit cdc53e774037733578df50a2663719f27dd9b41f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Jan 4 14:20:54 2016 +1300

    autobuild: Use cp --recursive --link --archive
    
    This works on waf based builds as source files are not modified during the build
    
    TODO: In order to make sure build doesn't influence each other,
    we need to add something like:
    
             try:
                 if options.rebase is not None:
                     rebase_tree(options.rebase, rebase_branch=options.branch)
    +            run_cmd("find -type f | xargs chmod -w", show=True, dir=test_master)
             except Exception:
    
    But that means we need to change the way 'make distcheck' works for the
    standalone libraries.
    
    For now this will help to reduce the (mem)disk usage of an autobuild a lot.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit cce16123feedfbf0e325182c6e301377d8a60749)

commit 69ea4baefdb858b33a72c2f8226d54a2292f6dd1
Author: Björn Baumbach <bb at sernet.de>
Date:   Fri Nov 18 18:54:56 2011 +0100

    s3-printing: fix migrate printer code (bug 8618)
    
    Removed path from driver files.
    We only need the basenames.
    (cherry picked from commit d61993043fcb7676a58658476421f5f4ff1a3fea)
    (cherry picked from commit 9f07ef2249dc21eab37cd5888623e6edc84b2b59)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=8618
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Wed Oct  5 19:19:39 CEST 2016 on sn-devel-144
    
    (cherry picked from commit eb7555397fd4e9f66e041179aadff59f2a39d14f)

commit 8e2589e07414f63e75833da1418300c10ba9f77a
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 12 11:06:51 2016 +0200

    spoolss: Fix caching of printername->sharename
    
    time_mono() gives seconds since boot, gencache expects seconds since epoch.
    With time_mono(), the values are always expired immediately.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12374
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Thu Oct 13 13:48:52 CEST 2016 on sn-devel-144

commit af851c2e3c3d5362b69ed8063419bc109bc9438f
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 24 10:45:13 2016 -0700

    glusterfs: Avoid tevent_internal.h
    
    Günther confirmed it still compiles :-)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Sat Sep 24 23:41:56 CEST 2016 on sn-devel-144
    
    (cherry picked from commit c60ea2c17814f9f7b55514e0d0a553accaa54b15)

commit a992329246c5d48d76d9408e36f78da890d659ab
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 20:00:33 2016 -0700

    s3: events. Move events.c to util_event.c
    
    Remove all tevent internal code.
    
    Everything is now stock tevent.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (similar to commit 4ed790ebbf474c4e4ef9b4f0f3aeca65118796df)

commit 51cad545d02718710cc4f34de98f323938b2e1af
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 19:11:17 2016 -0700

    s3: server: s3_tevent_context_init() -> samba_tevent_context_init()
    
    We can now remove source3/lib/events.c
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit fbfea52e1ce8f22d8d020a2bf3aebd1bc69faceb)

commit 70edf8c2fbe0a60018bd3dbc6dbc3d17043beb63
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 19:07:39 2016 -0700

    s3: winbind: Remove dump_event_list() calls.
    
    If needed we can add this into actual tevent.
    
    Preparing to remove source3/lib/events.c
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 72785309aa2d1bed7abc6dd7c6475ff0f78411da)

commit 0d0339bdc284cf5a8a0f604cb7be2cd99935fc7d
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:37:52 2016 -0700

    s3: nmbd: Final changeover to stock tevent for nmbd.
    
    Removes unused references to fds array used for (removed)
    poll call. Renames create_listen_pollfds() to
    create_listen_array().
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 6e8bd13660d7795df429dbf852345124db38ea96)

commit 4212718f2c211b994429ac38be003f6381a02ea2
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:31:00 2016 -0700

    s3: nmbd: Change over to using tevent functions from direct poll.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit b857bf9b3fa3a836647edc40ead92db7b782d367)

commit 6b134a8d499dc1f4f9bfb50614b769c19e689907
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:22:53 2016 -0700

    s3: nmbd: Add a talloc_stackframe().
    
    We will use this to create real tevent timer and fd
    events.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 36b67729a6fc8518da71944db3fac6d9236b9348)

commit 928f2814e80e3794b39b7e830f9fd25fe161e86a
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:18:37 2016 -0700

    s3: nmbd: Add (currently unused) timeout and fd handlers.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit cca25c8f75147873280464eaf2699ff449f609ad)

commit 9236d1cf58b33af598141a142f6e4fc2e4d491f5
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:16:58 2016 -0700

    s3: nmbd: Now attrs array mirrors fd's array use it in preference.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 376e04656b6755d1a182430b39273a93495d00b2)

commit 0918f181c5a333cfa29fd485f60045109d3d2f81
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:12:43 2016 -0700

    s3: nmbd: Ensure attrs array mirrors fd's array for dns.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7f0717e751930cd5da029c1852ff9f61f95e40b7)

commit 447b640638d616bb39916b55191a5f22a90d4e43
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 23 12:05:59 2016 -0700

    s3: nmbd: Add fd, triggered elements to struct socket_attributes.
    
    Zero the attrs array on allocation, and mirror the fd's.
    
    This will allow us to eventually remove source3/lib/events.c
    dependency and make nmbd purely tevent based.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12283
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit d8ade0730797df22bfe28847e034eb6d116b0e00)

commit de63f7dc012336364dee930541e1008324863892
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 09:29:47 2013 +0100

    s3:nmbd: fix talloc_zero_array() check in nmbd_packets.c
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Fri Sep 23 18:08:21 CEST 2016 on sn-devel-144
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12283
    
    (cherry picked from commit 4470f01605a2f09b054550ee5a8f8d3b4ebc2098)

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

Summary of changes:
 script/autobuild.py                         |  11 +-
 source3/include/includes.h                  |   4 +-
 source3/include/{event.h => util_event.h}   |  16 +-
 source3/lib/events.c                        | 486 ----------------------------
 source3/lib/server_contexts.c               |   2 +-
 source3/lib/util_event.c                    | 101 ++++++
 source3/libads/sasl.c                       |  11 -
 source3/modules/vfs_glusterfs.c             |   1 -
 source3/nmbd/nmbd_packets.c                 | 162 ++++++----
 source3/printing/nt_printing_migrate.c      |  27 ++
 source3/rpc_server/rpc_ncacn_np.c           |   8 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c |   4 +-
 source3/smbd/process.c                      |   4 +-
 source3/smbd/server.c                       |   1 -
 source3/winbindd/winbindd_dual.c            |   5 +-
 source3/wscript_build                       |   2 +-
 source4/heimdal/lib/krb5/mcache.c           |  52 ++-
 17 files changed, 285 insertions(+), 612 deletions(-)
 rename source3/include/{event.h => util_event.h} (64%)
 delete mode 100644 source3/lib/events.c
 create mode 100644 source3/lib/util_event.c


Changeset truncated at 500 lines:

diff --git a/script/autobuild.py b/script/autobuild.py
index 3777de7..4b43bc9 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -192,7 +192,7 @@ def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True):
 class builder(object):
     '''handle build of one directory'''
 
-    def __init__(self, name, sequence):
+    def __init__(self, name, sequence, cp=True):
         self.name = name
         self.dir = builddirs[name]
 
@@ -215,7 +215,10 @@ class builder(object):
         cleanup_list.append(self.prefix)
         os.makedirs(self.sdir)
         run_cmd("rm -rf %s" % self.sdir)
-        run_cmd("git clone --recursive --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True)
+        if cp:
+            run_cmd("cp --recursive --link --archive %s %s" % (test_master, self.sdir), dir=test_master, show=True)
+        else:
+            run_cmd("git clone --recursive --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True)
         self.start_next()
 
     def start_next(self):
@@ -254,7 +257,7 @@ class buildlist(object):
             os.environ['AUTOBUILD_RANDOM_SLEEP_OVERRIDE'] = '1'
 
         for n in tasknames:
-            b = builder(n, tasks[n])
+            b = builder(n, tasks[n], cp=n is not "pidl")
             self.tlist.append(b)
         if options.retry:
             rebase_remote = "rebaseon"
@@ -278,7 +281,7 @@ class buildlist(object):
                            ),
                            "test/plain" ) ]
 
-            self.retry = builder('retry', retry_task)
+            self.retry = builder('retry', retry_task, cp=False)
             self.need_retry = False
 
     def kill_kids(self):
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 81bba40..234a564 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -310,8 +310,8 @@ typedef char fstring[FSTRING_LEN];
 #include "../lib/util/dlinklist.h"
 
 #include <talloc.h>
-
-#include "event.h"
+#include <tevent.h>
+#include "util_event.h"
 
 #include "../lib/util/data_blob.h"
 #include "../lib/util/time.h"
diff --git a/source3/include/event.h b/source3/include/util_event.h
similarity index 64%
rename from source3/include/event.h
rename to source3/include/util_event.h
index 108026e..df608a1 100644
--- a/source3/include/event.h
+++ b/source3/include/util_event.h
@@ -18,21 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <tevent.h>
-
-/* The following definitions come from lib/events.c  */
-struct pollfd;
-struct timeval *get_timed_events_timeout(struct tevent_context *event_ctx,
-					 struct timeval *to_ret);
-void dump_event_list(struct tevent_context *event_ctx);
-struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx);
-
-bool event_add_to_poll_args(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
-			    struct pollfd **pfds, int *num_pfds,
-			    int *ptimeout);
-bool run_events_poll(struct tevent_context *ev, int pollrtn,
-		     struct pollfd *pfds, int num_pfds);
-
+/* The following definitions come from lib/util_event.c  */
 struct idle_event *event_add_idle(struct tevent_context *event_ctx,
 				  TALLOC_CTX *mem_ctx,
 				  struct timeval interval,
diff --git a/source3/lib/events.c b/source3/lib/events.c
deleted file mode 100644
index 0bc56e4..0000000
--- a/source3/lib/events.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Timed event library.
-   Copyright (C) Andrew Tridgell 1992-1998
-   Copyright (C) Volker Lendecke 2005-2007
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "lib/tevent/tevent_internal.h"
-#include "../lib/util/select.h"
-#include "system/select.h"
-
-struct tevent_poll_private {
-	/*
-	 * Index from file descriptor into the pollfd array
-	 */
-	int *pollfd_idx;
-
-	/*
-	 * Cache for s3_event_loop_once to avoid reallocs
-	 */
-	struct pollfd *pfds;
-};
-
-static struct tevent_poll_private *tevent_get_poll_private(
-	struct tevent_context *ev)
-{
-	struct tevent_poll_private *state;
-
-	state = (struct tevent_poll_private *)ev->additional_data;
-	if (state == NULL) {
-		state = talloc_zero(ev, struct tevent_poll_private);
-		ev->additional_data = (void *)state;
-		if (state == NULL) {
-			DEBUG(10, ("talloc failed\n"));
-		}
-	}
-	return state;
-}
-
-static void count_fds(struct tevent_context *ev,
-		      int *pnum_fds, int *pmax_fd)
-{
-	struct tevent_fd *fde;
-	int num_fds = 0;
-	int max_fd = 0;
-
-	for (fde = ev->fd_events; fde != NULL; fde = fde->next) {
-		if (fde->flags & (TEVENT_FD_READ|TEVENT_FD_WRITE)) {
-			num_fds += 1;
-			if (fde->fd > max_fd) {
-				max_fd = fde->fd;
-			}
-		}
-	}
-	*pnum_fds = num_fds;
-	*pmax_fd = max_fd;
-}
-
-bool event_add_to_poll_args(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
-			    struct pollfd **pfds, int *pnum_pfds,
-			    int *ptimeout)
-{
-	struct tevent_poll_private *state;
-	struct tevent_fd *fde;
-	int i, num_fds, max_fd, num_pollfds, idx_len;
-	struct pollfd *fds;
-	struct timeval now, diff;
-	int timeout;
-
-	state = tevent_get_poll_private(ev);
-	if (state == NULL) {
-		return false;
-	}
-	count_fds(ev, &num_fds, &max_fd);
-
-	idx_len = max_fd+1;
-
-	if (talloc_array_length(state->pollfd_idx) < idx_len) {
-		state->pollfd_idx = talloc_realloc(
-			state, state->pollfd_idx, int, idx_len);
-		if (state->pollfd_idx == NULL) {
-			DEBUG(10, ("talloc_realloc failed\n"));
-			return false;
-		}
-	}
-
-	fds = *pfds;
-	num_pollfds = *pnum_pfds;
-
-	if (talloc_array_length(fds) < num_pollfds + num_fds) {
-		fds = talloc_realloc(mem_ctx, fds, struct pollfd,
-					   num_pollfds + num_fds);
-		if (fds == NULL) {
-			DEBUG(10, ("talloc_realloc failed\n"));
-			return false;
-		}
-	}
-
-	memset(&fds[num_pollfds], 0, sizeof(struct pollfd) * num_fds);
-
-	/*
-	 * This needs tuning. We need to cope with multiple fde's for a file
-	 * descriptor. The problem is that we need to re-use pollfd_idx across
-	 * calls for efficiency. One way would be a direct bitmask that might
-	 * be initialized quicker, but our bitmap_init implementation is
-	 * pretty heavy-weight as well.
-	 */
-	for (i=0; i<idx_len; i++) {
-		state->pollfd_idx[i] = -1;
-	}
-
-	for (fde = ev->fd_events; fde; fde = fde->next) {
-		struct pollfd *pfd;
-
-		if ((fde->flags & (TEVENT_FD_READ|TEVENT_FD_WRITE)) == 0) {
-			continue;
-		}
-
-		if (state->pollfd_idx[fde->fd] == -1) {
-			/*
-			 * We haven't seen this fd yet. Allocate a new pollfd.
-			 */
-			state->pollfd_idx[fde->fd] = num_pollfds;
-			pfd = &fds[num_pollfds];
-			num_pollfds += 1;
-		} else {
-			/*
-			 * We have already seen this fd. OR in the flags.
-			 */
-			pfd = &fds[state->pollfd_idx[fde->fd]];
-		}
-
-		pfd->fd = fde->fd;
-
-		if (fde->flags & TEVENT_FD_READ) {
-			pfd->events |= (POLLIN|POLLHUP);
-		}
-		if (fde->flags & TEVENT_FD_WRITE) {
-			pfd->events |= POLLOUT;
-		}
-	}
-	*pfds = fds;
-	*pnum_pfds = num_pollfds;
-
-	if (ev->immediate_events != NULL) {
-		*ptimeout = 0;
-		return true;
-	}
-	if (ev->timer_events == NULL) {
-		*ptimeout = MIN(*ptimeout, INT_MAX);
-		return true;
-	}
-
-	now = timeval_current();
-	diff = timeval_until(&now, &ev->timer_events->next_event);
-	timeout = timeval_to_msec(diff);
-
-	if (timeout < *ptimeout) {
-		*ptimeout = timeout;
-	}
-
-	return true;
-}
-
-bool run_events_poll(struct tevent_context *ev, int pollrtn,
-		     struct pollfd *pfds, int num_pfds)
-{
-	struct tevent_poll_private *state;
-	int *pollfd_idx;
-	struct tevent_fd *fde;
-
-	if (ev->signal_events &&
-	    tevent_common_check_signal(ev)) {
-		return true;
-	}
-
-	if (ev->immediate_events &&
-	    tevent_common_loop_immediate(ev)) {
-		return true;
-	}
-
-	if (pollrtn <= 0) {
-		struct timeval tval;
-
-		tval = tevent_common_loop_timer_delay(ev);
-		if (tevent_timeval_is_zero(&tval)) {
-			return true;
-		}
-
-		/*
-		 * No fd ready
-		 */
-		return false;
-	}
-
-	state = (struct tevent_poll_private *)ev->additional_data;
-	pollfd_idx = state->pollfd_idx;
-
-	for (fde = ev->fd_events; fde; fde = fde->next) {
-		struct pollfd *pfd;
-		uint16_t flags = 0;
-
-		if ((fde->flags & (TEVENT_FD_READ|TEVENT_FD_WRITE)) == 0) {
-			continue;
-		}
-
-		if (pollfd_idx[fde->fd] >= num_pfds) {
-			DEBUG(1, ("internal error: pollfd_idx[fde->fd] (%d) "
-				  ">= num_pfds (%d)\n", pollfd_idx[fde->fd],
-				  num_pfds));
-			return false;
-		}
-		pfd = &pfds[pollfd_idx[fde->fd]];
-
-		if (pfd->fd != fde->fd) {
-			DEBUG(1, ("internal error: pfd->fd (%d) "
-				  "!= fde->fd (%d)\n", pollfd_idx[fde->fd],
-                                  num_pfds));
-			return false;
-		}
-
-		if (pfd->revents & (POLLHUP|POLLERR)) {
-			/* If we only wait for TEVENT_FD_WRITE, we
-			   should not tell the event handler about it,
-			   and remove the writable flag, as we only
-			   report errors when waiting for read events
-			   to match the select behavior. */
-			if (!(fde->flags & TEVENT_FD_READ)) {
-				TEVENT_FD_NOT_WRITEABLE(fde);
-				continue;
-			}
-			flags |= TEVENT_FD_READ;
-		}
-
-		if (pfd->revents & POLLIN) {
-			flags |= TEVENT_FD_READ;
-		}
-		if (pfd->revents & POLLOUT) {
-			flags |= TEVENT_FD_WRITE;
-		}
-		if (flags & fde->flags) {
-			DLIST_DEMOTE(ev->fd_events, fde, struct tevent_fd);
-			fde->handler(ev, fde, flags, fde->private_data);
-			return true;
-		}
-	}
-
-	return false;
-}
-
-struct timeval *get_timed_events_timeout(struct tevent_context *ev,
-					 struct timeval *to_ret)
-{
-	struct timeval now;
-
-	if ((ev->timer_events == NULL) && (ev->immediate_events == NULL)) {
-		return NULL;
-	}
-	if (ev->immediate_events != NULL) {
-		*to_ret = timeval_zero();
-		return to_ret;
-	}
-
-	now = timeval_current();
-	*to_ret = timeval_until(&now, &ev->timer_events->next_event);
-
-	DEBUG(10, ("timed_events_timeout: %d/%d\n", (int)to_ret->tv_sec,
-		(int)to_ret->tv_usec));
-
-	return to_ret;
-}
-
-static int s3_event_loop_once(struct tevent_context *ev, const char *location)
-{
-	struct tevent_poll_private *state;
-	int timeout;
-	int num_pfds;
-	int ret;
-	int poll_errno;
-
-	timeout = INT_MAX;
-
-	state = tevent_get_poll_private(ev);
-	if (state == NULL) {
-		errno = ENOMEM;
-		return -1;
-	}
-
-	if (run_events_poll(ev, 0, NULL, 0)) {
-		return 0;
-	}
-
-	num_pfds = 0;
-	if (!event_add_to_poll_args(ev, state,
-				    &state->pfds, &num_pfds, &timeout)) {
-		return -1;
-	}
-
-	tevent_trace_point_callback(ev, TEVENT_TRACE_BEFORE_WAIT);
-	ret = poll(state->pfds, num_pfds, timeout);
-	poll_errno = errno;
-	tevent_trace_point_callback(ev, TEVENT_TRACE_AFTER_WAIT);
-	errno = poll_errno;
-
-	if (ret == -1 && errno != EINTR) {
-		tevent_debug(ev, TEVENT_DEBUG_FATAL,
-			     "poll() failed: %d:%s\n",
-			     errno, strerror(errno));
-		return -1;
-	}
-
-	run_events_poll(ev, ret, state->pfds, num_pfds);
-	return 0;
-}
-
-static int s3_event_context_init(struct tevent_context *ev)
-{
-	return 0;
-}
-
-void dump_event_list(struct tevent_context *ev)
-{
-	struct tevent_timer *te;
-	struct tevent_fd *fe;
-	struct timeval evt, now;
-
-	if (!ev) {
-		return;
-	}
-
-	now = timeval_current();
-
-	DEBUG(10,("dump_event_list:\n"));
-
-	for (te = ev->timer_events; te; te = te->next) {
-
-		evt = timeval_until(&now, &te->next_event);
-
-		DEBUGADD(10,("Timed Event \"%s\" %p handled in %d seconds (at %s)\n",
-			   te->handler_name,
-			   te,
-			   (int)evt.tv_sec,
-			   http_timestring(talloc_tos(), te->next_event.tv_sec)));
-	}
-
-	for (fe = ev->fd_events; fe; fe = fe->next) {
-
-		DEBUGADD(10,("FD Event %d %p, flags: 0x%04x\n",
-			   fe->fd,
-			   fe,
-			   fe->flags));
-	}
-}
-
-static const struct tevent_ops s3_event_ops = {
-	.context_init		= s3_event_context_init,
-	.add_fd			= tevent_common_add_fd,
-	.set_fd_close_fn	= tevent_common_fd_set_close_fn,
-	.get_fd_flags		= tevent_common_fd_get_flags,
-	.set_fd_flags		= tevent_common_fd_set_flags,
-	.add_timer		= tevent_common_add_timer,
-	.schedule_immediate	= tevent_common_schedule_immediate,
-	.add_signal		= tevent_common_add_signal,
-	.loop_once		= s3_event_loop_once,
-	.loop_wait		= tevent_common_loop_wait,
-};
-
-static bool s3_tevent_init(void)
-{
-	static bool initialized;
-	if (initialized) {
-		return true;
-	}
-	initialized = tevent_register_backend("s3", &s3_event_ops);
-	tevent_set_default_backend("s3");
-	return initialized;
-}
-
-struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx)
-{
-	struct tevent_context *ev;
-
-	s3_tevent_init();
-
-	ev = tevent_context_init_byname(mem_ctx, "s3");
-	if (ev) {
-		samba_tevent_set_debug(ev, "s3_tevent");
-	}
-
-	return ev;
-}
-


-- 
Samba Shared Repository



More information about the samba-cvs mailing list