[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#840188: jessie-pu: package tevent/0.9.25-0+deb8u1



Package: release.debian.org
Severity: normal
Tags: jessie
User: release.debian.org@packages.debian.org
Usertags: pu

I would like to update tevent in jessie to 0.9.28. This is necessary,
because the proposed version of Samba depends on new features
(https://bugs.debian.org/836795).

Debdiff attached.

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable'), (500, 'stable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff -Nru tevent-0.9.25/ABI/tevent-0.9.26.sigs tevent-0.9.28/ABI/tevent-0.9.26.sigs
--- tevent-0.9.25/ABI/tevent-0.9.26.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/ABI/tevent-0.9.26.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,90 @@
+_tevent_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+_tevent_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+_tevent_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+_tevent_create_immediate: struct tevent_immediate *(TALLOC_CTX *, const char *)
+_tevent_loop_once: int (struct tevent_context *, const char *)
+_tevent_loop_until: int (struct tevent_context *, bool (*)(void *), void *, const char *)
+_tevent_loop_wait: int (struct tevent_context *, const char *)
+_tevent_queue_create: struct tevent_queue *(TALLOC_CTX *, const char *, const char *)
+_tevent_req_callback_data: void *(struct tevent_req *)
+_tevent_req_cancel: bool (struct tevent_req *, const char *)
+_tevent_req_create: struct tevent_req *(TALLOC_CTX *, void *, size_t, const char *, const char *)
+_tevent_req_data: void *(struct tevent_req *)
+_tevent_req_done: void (struct tevent_req *, const char *)
+_tevent_req_error: bool (struct tevent_req *, uint64_t, const char *)
+_tevent_req_nomem: bool (const void *, struct tevent_req *, const char *)
+_tevent_req_notify_callback: void (struct tevent_req *, const char *)
+_tevent_req_oom: void (struct tevent_req *, const char *)
+_tevent_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_backend_list: const char **(TALLOC_CTX *)
+tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *)
+tevent_common_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+tevent_common_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+tevent_common_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_add_timer_v2: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_check_signal: int (struct tevent_context *)
+tevent_common_context_destructor: int (struct tevent_context *)
+tevent_common_fd_destructor: int (struct tevent_fd *)
+tevent_common_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_common_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_common_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_common_loop_immediate: bool (struct tevent_context *)
+tevent_common_loop_timer_delay: struct timeval (struct tevent_context *)
+tevent_common_loop_wait: int (struct tevent_context *, const char *)
+tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_context_init: struct tevent_context *(TALLOC_CTX *)
+tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
+tevent_context_init_ops: struct tevent_context *(TALLOC_CTX *, const struct tevent_ops *, void *)
+tevent_debug: void (struct tevent_context *, enum tevent_debug_level, const char *, ...)
+tevent_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_fd_set_auto_close: void (struct tevent_fd *)
+tevent_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_get_trace_callback: void (struct tevent_context *, tevent_trace_callback_t *, void *)
+tevent_loop_allow_nesting: void (struct tevent_context *)
+tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
+tevent_num_signals: size_t (void)
+tevent_queue_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_entry: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_optimize_empty: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_length: size_t (struct tevent_queue *)
+tevent_queue_running: bool (struct tevent_queue *)
+tevent_queue_start: void (struct tevent_queue *)
+tevent_queue_stop: void (struct tevent_queue *)
+tevent_queue_wait_recv: bool (struct tevent_req *)
+tevent_queue_wait_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct tevent_queue *)
+tevent_re_initialise: int (struct tevent_context *)
+tevent_register_backend: bool (const char *, const struct tevent_ops *)
+tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
+tevent_req_defer_callback: void (struct tevent_req *, struct tevent_context *)
+tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *)
+tevent_req_is_in_progress: bool (struct tevent_req *)
+tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)
+tevent_req_post: struct tevent_req *(struct tevent_req *, struct tevent_context *)
+tevent_req_print: char *(TALLOC_CTX *, struct tevent_req *)
+tevent_req_received: void (struct tevent_req *)
+tevent_req_set_callback: void (struct tevent_req *, tevent_req_fn, void *)
+tevent_req_set_cancel_fn: void (struct tevent_req *, tevent_req_cancel_fn)
+tevent_req_set_cleanup_fn: void (struct tevent_req *, tevent_req_cleanup_fn)
+tevent_req_set_endtime: bool (struct tevent_req *, struct tevent_context *, struct timeval)
+tevent_req_set_print_fn: void (struct tevent_req *, tevent_req_print_fn)
+tevent_sa_info_queue_count: size_t (void)
+tevent_set_abort_fn: void (void (*)(const char *))
+tevent_set_debug: int (struct tevent_context *, void (*)(void *, enum tevent_debug_level, const char *, va_list), void *)
+tevent_set_debug_stderr: int (struct tevent_context *)
+tevent_set_default_backend: void (const char *)
+tevent_set_trace_callback: void (struct tevent_context *, tevent_trace_callback_t, void *)
+tevent_signal_support: bool (struct tevent_context *)
+tevent_thread_proxy_create: struct tevent_thread_proxy *(struct tevent_context *)
+tevent_thread_proxy_schedule: void (struct tevent_thread_proxy *, struct tevent_immediate **, tevent_immediate_handler_t, void *)
+tevent_timeval_add: struct timeval (const struct timeval *, uint32_t, uint32_t)
+tevent_timeval_compare: int (const struct timeval *, const struct timeval *)
+tevent_timeval_current: struct timeval (void)
+tevent_timeval_current_ofs: struct timeval (uint32_t, uint32_t)
+tevent_timeval_is_zero: bool (const struct timeval *)
+tevent_timeval_set: struct timeval (uint32_t, uint32_t)
+tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *)
+tevent_timeval_zero: struct timeval (void)
+tevent_trace_point_callback: void (struct tevent_context *, enum tevent_trace_point)
+tevent_wakeup_recv: bool (struct tevent_req *)
+tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval)
diff -Nru tevent-0.9.25/ABI/tevent-0.9.27.sigs tevent-0.9.28/ABI/tevent-0.9.27.sigs
--- tevent-0.9.25/ABI/tevent-0.9.27.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/ABI/tevent-0.9.27.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,90 @@
+_tevent_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+_tevent_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+_tevent_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+_tevent_create_immediate: struct tevent_immediate *(TALLOC_CTX *, const char *)
+_tevent_loop_once: int (struct tevent_context *, const char *)
+_tevent_loop_until: int (struct tevent_context *, bool (*)(void *), void *, const char *)
+_tevent_loop_wait: int (struct tevent_context *, const char *)
+_tevent_queue_create: struct tevent_queue *(TALLOC_CTX *, const char *, const char *)
+_tevent_req_callback_data: void *(struct tevent_req *)
+_tevent_req_cancel: bool (struct tevent_req *, const char *)
+_tevent_req_create: struct tevent_req *(TALLOC_CTX *, void *, size_t, const char *, const char *)
+_tevent_req_data: void *(struct tevent_req *)
+_tevent_req_done: void (struct tevent_req *, const char *)
+_tevent_req_error: bool (struct tevent_req *, uint64_t, const char *)
+_tevent_req_nomem: bool (const void *, struct tevent_req *, const char *)
+_tevent_req_notify_callback: void (struct tevent_req *, const char *)
+_tevent_req_oom: void (struct tevent_req *, const char *)
+_tevent_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_backend_list: const char **(TALLOC_CTX *)
+tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *)
+tevent_common_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+tevent_common_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+tevent_common_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_add_timer_v2: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_check_signal: int (struct tevent_context *)
+tevent_common_context_destructor: int (struct tevent_context *)
+tevent_common_fd_destructor: int (struct tevent_fd *)
+tevent_common_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_common_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_common_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_common_loop_immediate: bool (struct tevent_context *)
+tevent_common_loop_timer_delay: struct timeval (struct tevent_context *)
+tevent_common_loop_wait: int (struct tevent_context *, const char *)
+tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_context_init: struct tevent_context *(TALLOC_CTX *)
+tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
+tevent_context_init_ops: struct tevent_context *(TALLOC_CTX *, const struct tevent_ops *, void *)
+tevent_debug: void (struct tevent_context *, enum tevent_debug_level, const char *, ...)
+tevent_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_fd_set_auto_close: void (struct tevent_fd *)
+tevent_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_get_trace_callback: void (struct tevent_context *, tevent_trace_callback_t *, void *)
+tevent_loop_allow_nesting: void (struct tevent_context *)
+tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
+tevent_num_signals: size_t (void)
+tevent_queue_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_entry: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_optimize_empty: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_length: size_t (struct tevent_queue *)
+tevent_queue_running: bool (struct tevent_queue *)
+tevent_queue_start: void (struct tevent_queue *)
+tevent_queue_stop: void (struct tevent_queue *)
+tevent_queue_wait_recv: bool (struct tevent_req *)
+tevent_queue_wait_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct tevent_queue *)
+tevent_re_initialise: int (struct tevent_context *)
+tevent_register_backend: bool (const char *, const struct tevent_ops *)
+tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
+tevent_req_defer_callback: void (struct tevent_req *, struct tevent_context *)
+tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *)
+tevent_req_is_in_progress: bool (struct tevent_req *)
+tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)
+tevent_req_post: struct tevent_req *(struct tevent_req *, struct tevent_context *)
+tevent_req_print: char *(TALLOC_CTX *, struct tevent_req *)
+tevent_req_received: void (struct tevent_req *)
+tevent_req_set_callback: void (struct tevent_req *, tevent_req_fn, void *)
+tevent_req_set_cancel_fn: void (struct tevent_req *, tevent_req_cancel_fn)
+tevent_req_set_cleanup_fn: void (struct tevent_req *, tevent_req_cleanup_fn)
+tevent_req_set_endtime: bool (struct tevent_req *, struct tevent_context *, struct timeval)
+tevent_req_set_print_fn: void (struct tevent_req *, tevent_req_print_fn)
+tevent_sa_info_queue_count: size_t (void)
+tevent_set_abort_fn: void (void (*)(const char *))
+tevent_set_debug: int (struct tevent_context *, void (*)(void *, enum tevent_debug_level, const char *, va_list), void *)
+tevent_set_debug_stderr: int (struct tevent_context *)
+tevent_set_default_backend: void (const char *)
+tevent_set_trace_callback: void (struct tevent_context *, tevent_trace_callback_t, void *)
+tevent_signal_support: bool (struct tevent_context *)
+tevent_thread_proxy_create: struct tevent_thread_proxy *(struct tevent_context *)
+tevent_thread_proxy_schedule: void (struct tevent_thread_proxy *, struct tevent_immediate **, tevent_immediate_handler_t, void *)
+tevent_timeval_add: struct timeval (const struct timeval *, uint32_t, uint32_t)
+tevent_timeval_compare: int (const struct timeval *, const struct timeval *)
+tevent_timeval_current: struct timeval (void)
+tevent_timeval_current_ofs: struct timeval (uint32_t, uint32_t)
+tevent_timeval_is_zero: bool (const struct timeval *)
+tevent_timeval_set: struct timeval (uint32_t, uint32_t)
+tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *)
+tevent_timeval_zero: struct timeval (void)
+tevent_trace_point_callback: void (struct tevent_context *, enum tevent_trace_point)
+tevent_wakeup_recv: bool (struct tevent_req *)
+tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval)
diff -Nru tevent-0.9.25/ABI/tevent-0.9.28.sigs tevent-0.9.28/ABI/tevent-0.9.28.sigs
--- tevent-0.9.25/ABI/tevent-0.9.28.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/ABI/tevent-0.9.28.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,90 @@
+_tevent_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+_tevent_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+_tevent_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+_tevent_create_immediate: struct tevent_immediate *(TALLOC_CTX *, const char *)
+_tevent_loop_once: int (struct tevent_context *, const char *)
+_tevent_loop_until: int (struct tevent_context *, bool (*)(void *), void *, const char *)
+_tevent_loop_wait: int (struct tevent_context *, const char *)
+_tevent_queue_create: struct tevent_queue *(TALLOC_CTX *, const char *, const char *)
+_tevent_req_callback_data: void *(struct tevent_req *)
+_tevent_req_cancel: bool (struct tevent_req *, const char *)
+_tevent_req_create: struct tevent_req *(TALLOC_CTX *, void *, size_t, const char *, const char *)
+_tevent_req_data: void *(struct tevent_req *)
+_tevent_req_done: void (struct tevent_req *, const char *)
+_tevent_req_error: bool (struct tevent_req *, uint64_t, const char *)
+_tevent_req_nomem: bool (const void *, struct tevent_req *, const char *)
+_tevent_req_notify_callback: void (struct tevent_req *, const char *)
+_tevent_req_oom: void (struct tevent_req *, const char *)
+_tevent_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_backend_list: const char **(TALLOC_CTX *)
+tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *)
+tevent_common_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+tevent_common_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+tevent_common_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_add_timer_v2: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_check_signal: int (struct tevent_context *)
+tevent_common_context_destructor: int (struct tevent_context *)
+tevent_common_fd_destructor: int (struct tevent_fd *)
+tevent_common_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_common_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_common_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_common_loop_immediate: bool (struct tevent_context *)
+tevent_common_loop_timer_delay: struct timeval (struct tevent_context *)
+tevent_common_loop_wait: int (struct tevent_context *, const char *)
+tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_context_init: struct tevent_context *(TALLOC_CTX *)
+tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
+tevent_context_init_ops: struct tevent_context *(TALLOC_CTX *, const struct tevent_ops *, void *)
+tevent_debug: void (struct tevent_context *, enum tevent_debug_level, const char *, ...)
+tevent_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_fd_set_auto_close: void (struct tevent_fd *)
+tevent_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_get_trace_callback: void (struct tevent_context *, tevent_trace_callback_t *, void *)
+tevent_loop_allow_nesting: void (struct tevent_context *)
+tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
+tevent_num_signals: size_t (void)
+tevent_queue_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_entry: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_optimize_empty: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_length: size_t (struct tevent_queue *)
+tevent_queue_running: bool (struct tevent_queue *)
+tevent_queue_start: void (struct tevent_queue *)
+tevent_queue_stop: void (struct tevent_queue *)
+tevent_queue_wait_recv: bool (struct tevent_req *)
+tevent_queue_wait_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct tevent_queue *)
+tevent_re_initialise: int (struct tevent_context *)
+tevent_register_backend: bool (const char *, const struct tevent_ops *)
+tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
+tevent_req_defer_callback: void (struct tevent_req *, struct tevent_context *)
+tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *)
+tevent_req_is_in_progress: bool (struct tevent_req *)
+tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)
+tevent_req_post: struct tevent_req *(struct tevent_req *, struct tevent_context *)
+tevent_req_print: char *(TALLOC_CTX *, struct tevent_req *)
+tevent_req_received: void (struct tevent_req *)
+tevent_req_set_callback: void (struct tevent_req *, tevent_req_fn, void *)
+tevent_req_set_cancel_fn: void (struct tevent_req *, tevent_req_cancel_fn)
+tevent_req_set_cleanup_fn: void (struct tevent_req *, tevent_req_cleanup_fn)
+tevent_req_set_endtime: bool (struct tevent_req *, struct tevent_context *, struct timeval)
+tevent_req_set_print_fn: void (struct tevent_req *, tevent_req_print_fn)
+tevent_sa_info_queue_count: size_t (void)
+tevent_set_abort_fn: void (void (*)(const char *))
+tevent_set_debug: int (struct tevent_context *, void (*)(void *, enum tevent_debug_level, const char *, va_list), void *)
+tevent_set_debug_stderr: int (struct tevent_context *)
+tevent_set_default_backend: void (const char *)
+tevent_set_trace_callback: void (struct tevent_context *, tevent_trace_callback_t, void *)
+tevent_signal_support: bool (struct tevent_context *)
+tevent_thread_proxy_create: struct tevent_thread_proxy *(struct tevent_context *)
+tevent_thread_proxy_schedule: void (struct tevent_thread_proxy *, struct tevent_immediate **, tevent_immediate_handler_t, void *)
+tevent_timeval_add: struct timeval (const struct timeval *, uint32_t, uint32_t)
+tevent_timeval_compare: int (const struct timeval *, const struct timeval *)
+tevent_timeval_current: struct timeval (void)
+tevent_timeval_current_ofs: struct timeval (uint32_t, uint32_t)
+tevent_timeval_is_zero: bool (const struct timeval *)
+tevent_timeval_set: struct timeval (uint32_t, uint32_t)
+tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *)
+tevent_timeval_zero: struct timeval (void)
+tevent_trace_point_callback: void (struct tevent_context *, enum tevent_trace_point)
+tevent_wakeup_recv: bool (struct tevent_req *)
+tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval)
diff -Nru tevent-0.9.25/buildtools/wafsamba/configure_file.py tevent-0.9.28/buildtools/wafsamba/configure_file.py
--- tevent-0.9.25/buildtools/wafsamba/configure_file.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/configure_file.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,18 +1,15 @@
 # handle substitution of variables in .in files
 
+import re, os
 import Build, sys, Logs
-from samba_utils import *
+from samba_utils import SUBST_VARS_RECURSIVE
 
 def subst_at_vars(task):
     '''substiture @VAR@ style variables in a file'''
 
     env = task.env
-    src = task.inputs[0].srcpath(env)
-    tgt = task.outputs[0].bldpath(env)
+    s = task.inputs[0].read()
 
-    f = open(src, 'r')
-    s = f.read()
-    f.close()
     # split on the vars
     a = re.split('(@\w+@)', s)
     out = []
@@ -27,9 +24,7 @@
             v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
         out.append(v)
     contents = ''.join(out)
-    f = open(tgt, 'w')
-    s = f.write(contents)
-    f.close()
+    task.outputs[0].write(contents)
     return 0
 
 def CONFIGURE_FILE(bld, in_file, **kwargs):
diff -Nru tevent-0.9.25/buildtools/wafsamba/gccdeps.py tevent-0.9.28/buildtools/wafsamba/gccdeps.py
--- tevent-0.9.25/buildtools/wafsamba/gccdeps.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/gccdeps.py	1970-01-01 00:00:00.000000000 +0000
@@ -1,127 +0,0 @@
-# encoding: utf-8
-# Thomas Nagy, 2008-2010 (ita)
-
-"""
-Execute the tasks with gcc -MD, read the dependencies from the .d file
-and prepare the dependency calculation for the next run
-"""
-
-import os, re, threading
-import Task, Logs, Utils, preproc
-from TaskGen import before, after, feature
-
-lock = threading.Lock()
-
-preprocessor_flag = '-MD'
-
-@feature('cc')
-@before('apply_core')
-def add_mmd_cc(self):
-    if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
-        self.env.append_value('CCFLAGS', preprocessor_flag)
-
-@feature('cxx')
-@before('apply_core')
-def add_mmd_cxx(self):
-    if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
-        self.env.append_value('CXXFLAGS', preprocessor_flag)
-
-def scan(self):
-    "the scanner does not do anything initially"
-    nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
-    names = []
-    return (nodes, names)
-
-re_o = re.compile("\.o$")
-re_src = re.compile("^(\.\.)[\\/](.*)$")
-
-def post_run(self):
-    # The following code is executed by threads, it is not safe, so a lock is needed...
-
-    if getattr(self, 'cached', None):
-        return Task.Task.post_run(self)
-
-    name = self.outputs[0].abspath(self.env)
-    name = re_o.sub('.d', name)
-    txt = Utils.readf(name)
-    #os.unlink(name)
-
-    txt = txt.replace('\\\n', '')
-
-    lst = txt.strip().split(':')
-    val = ":".join(lst[1:])
-    val = val.split()
-
-    nodes = []
-    bld = self.generator.bld
-
-    f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
-    for x in val:
-        if os.path.isabs(x):
-
-            if not preproc.go_absolute:
-                continue
-
-            lock.acquire()
-            try:
-                node = bld.root.find_resource(x)
-            finally:
-                lock.release()
-        else:
-            g = re.search(re_src, x)
-            if g:
-                x = g.group(2)
-                lock.acquire()
-                try:
-                    node = bld.bldnode.parent.find_resource(x)
-                finally:
-                    lock.release()
-            else:
-                g = re.search(f, x)
-                if g:
-                    x = g.group(2)
-                    lock.acquire()
-                    try:
-                        node = bld.srcnode.find_resource(x)
-                    finally:
-                        lock.release()
-
-        if id(node) == id(self.inputs[0]):
-            # ignore the source file, it is already in the dependencies
-            # this way, successful config tests may be retrieved from the cache
-            continue
-
-        if not node:
-            raise ValueError('could not find %r for %r' % (x, self))
-        else:
-            nodes.append(node)
-
-    Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
-
-    bld.node_deps[self.unique_id()] = nodes
-    bld.raw_deps[self.unique_id()] = []
-
-    try:
-        del self.cache_sig
-    except:
-        pass
-
-    Task.Task.post_run(self)
-
-import Constants, Utils
-def sig_implicit_deps(self):
-    try:
-        return Task.Task.sig_implicit_deps(self)
-    except Utils.WafError:
-        return Constants.SIG_NIL
-
-for name in 'cc cxx'.split():
-    try:
-        cls = Task.TaskBase.classes[name]
-    except KeyError:
-        pass
-    else:
-        cls.post_run = post_run
-        cls.scan = scan
-        cls.sig_implicit_deps = sig_implicit_deps
-
diff -Nru tevent-0.9.25/buildtools/wafsamba/nothreads.py tevent-0.9.28/buildtools/wafsamba/nothreads.py
--- tevent-0.9.25/buildtools/wafsamba/nothreads.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/nothreads.py	2016-02-26 03:24:44.000000000 +0000
@@ -10,12 +10,11 @@
 
 "Execute the tasks"
 
-import sys, random, time, threading, traceback, os
+import sys, random, threading
 try: from Queue import Queue
 except ImportError: from queue import Queue
-import Build, Utils, Logs, Options
-from Logs import debug, error
-from Constants import *
+import Utils, Options
+from Constants import EXCEPTION, CRASHED, MAXJOBS, ASK_LATER, SKIPPED, SKIP_ME, SUCCESS
 
 GAP = 15
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/pkgconfig.py tevent-0.9.28/buildtools/wafsamba/pkgconfig.py
--- tevent-0.9.25/buildtools/wafsamba/pkgconfig.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/pkgconfig.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,16 +1,13 @@
 # handle substitution of variables in pc files
 
-import Build, sys, Logs
-from samba_utils import *
+import os, re, sys
+import Build, Logs
+from samba_utils import SUBST_VARS_RECURSIVE, TO_LIST
 
 def subst_at_vars(task):
     '''substiture @VAR@ style variables in a file'''
-    src = task.inputs[0].srcpath(task.env)
-    tgt = task.outputs[0].bldpath(task.env)
 
-    f = open(src, 'r')
-    s = f.read()
-    f.close()
+    s = task.inputs[0].read()
     # split on the vars
     a = re.split('(@\w+@)', s)
     out = []
@@ -37,9 +34,7 @@
                     break
         out.append(v)
     contents = ''.join(out)
-    f = open(tgt, 'w')
-    s = f.write(contents)
-    f.close()
+    task.outputs[0].write(contents)
     return 0
 
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_abi.py tevent-0.9.28/buildtools/wafsamba/samba_abi.py
--- tevent-0.9.25/buildtools/wafsamba/samba_abi.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_abi.py	2016-02-26 03:24:44.000000000 +0000
@@ -137,7 +137,8 @@
     topsrc = self.bld.srcnode.abspath()
     abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh')
 
-    abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.name, self.vnum)
+    abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname,
+                                  self.vnum)
 
     tsk = self.create_task('abi_check', self.link_task.outputs[0])
     tsk.ABI_FILE = abi_file
@@ -147,12 +148,10 @@
 
 def abi_process_file(fname, version, symmap):
     '''process one ABI file, adding new symbols to the symmap'''
-    f = open(fname, mode='r')
-    for line in f:
+    for line in Utils.readf(fname).splitlines():
         symname = line.split(":")[0]
         if not symname in symmap:
             symmap[symname] = version
-    f.close()
 
 
 def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
@@ -226,7 +225,7 @@
 def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     '''generate a vscript file for our public libraries'''
     if abi_directory:
-        source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname))
+        source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname), flat=True)
         def abi_file_key(path):
             return version_key(path[:-len(".sigs")].rsplit("-")[-1])
         source = sorted(source.split(), key=abi_file_key)
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_autoconf.py tevent-0.9.28/buildtools/wafsamba/samba_autoconf.py
--- tevent-0.9.25/buildtools/wafsamba/samba_autoconf.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_autoconf.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,10 +1,10 @@
 # a waf tool to add autoconf-like macros to the configure section
 
-import Build, os, sys, Options, preproc, Logs
-import string
+import os, sys
+import Build, Options, preproc, Logs
 from Configure import conf
-from samba_utils import *
-import samba_cross
+from TaskGen import feature
+from samba_utils import TO_LIST, GET_TARGET_TYPE, SET_TARGET_TYPE, unique_list, mkdir_p
 
 missing_headers = set()
 
@@ -13,7 +13,6 @@
 # to waf a bit easier for those used to autoconf
 # m4 files
 
-@runonce
 @conf
 def DEFINE(conf, d, v, add_to_cflags=False, quote=False):
     '''define a config option'''
@@ -101,6 +100,7 @@
                      type='nolink',
                      execute=0,
                      ccflags=ccflags,
+                     mandatory=False,
                      includes=cpppath,
                      uselib=lib.upper(),
                      msg="Checking for header %s" % h)
@@ -229,7 +229,18 @@
                               headers=headers,
                               msg='Checking for declaration of %s' % v,
                               always=always):
-            ret = False
+            if not CHECK_CODE(conf,
+                      '''
+                      return (int)%s;
+                      ''' % (v),
+                      execute=False,
+                      link=False,
+                      msg='Checking for declaration of %s (as enum)' % v,
+                      local_include=False,
+                      headers=headers,
+                      define=define,
+                      always=always):
+                ret = False
     return ret
 
 
@@ -475,6 +486,7 @@
     return conf.check(fragment='int main(void) { return 0; }\n',
                       execute=0,
                       ldflags=ldflags,
+                      mandatory=False,
                       msg="Checking linker accepts %s" % ldflags)
 
 
@@ -558,9 +570,9 @@
 
         (ccflags, ldflags, cpppath) = library_flags(conf, lib)
         if shlib:
-            res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
+            res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)
         else:
-            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
+            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)
 
         if not res:
             if mandatory:
@@ -646,9 +658,24 @@
     if not IN_LAUNCH_DIR(conf):
         return
 
-    if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
-        conf.ADD_CFLAGS('-fstack-protector')
-        conf.ADD_LDFLAGS('-fstack-protector')
+    # we need to build real code that can't be optimized away to test
+    if conf.check(fragment='''
+        #include <stdio.h>
+
+        int main(void)
+        {
+            char t[100000];
+            while (fgets(t, sizeof(t), stdin));
+            return 0;
+        }
+        ''',
+        execute=0,
+        ccflags='-fstack-protector',
+        ldflags='-fstack-protector',
+        mandatory=False,
+        msg='Checking if toolchain accepts -fstack-protector'):
+            conf.ADD_CFLAGS('-fstack-protector')
+            conf.ADD_LDFLAGS('-fstack-protector')
 
     if Options.options.debug:
         conf.ADD_CFLAGS('-g', testflags=True)
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_autoproto.py tevent-0.9.28/buildtools/wafsamba/samba_autoproto.py
--- tevent-0.9.25/buildtools/wafsamba/samba_autoproto.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_autoproto.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,7 +1,8 @@
 # waf build tool for building automatic prototypes from C source
 
+import os
 import Build
-from samba_utils import *
+from samba_utils import SET_TARGET_TYPE, os_path_relpath
 
 def SAMBA_AUTOPROTO(bld, header, source):
     '''rule for samba prototype generation'''
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_bundled.py tevent-0.9.28/buildtools/wafsamba/samba_bundled.py
--- tevent-0.9.25/buildtools/wafsamba/samba_bundled.py	2014-12-22 08:17:09.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_bundled.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,8 +1,9 @@
 # functions to support bundled libraries
 
+import sys
+import Build, Options, Logs
 from Configure import conf
-import sys, Logs
-from samba_utils import *
+from samba_utils import TO_LIST
 
 def PRIVATE_NAME(bld, name, private_extension, private_library):
     '''possibly rename a library to include a bundled extension'''
@@ -108,17 +109,6 @@
             libname in conf.env.PRIVATE_LIBS)
 
 @conf
-def CHECK_PREREQUISITES(conf, prereqs):
-    missing = []
-    for syslib in TO_LIST(prereqs):
-        f = 'FOUND_SYSTEMLIB_%s' % syslib
-        if not f in conf.env:
-            missing.append(syslib)
-    return missing
-
-
-@runonce
-@conf
 def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
         onlyif=None, implied_deps=None, pkg=None):
     '''check if a library is available as a system library.
@@ -131,7 +121,6 @@
                                      implied_deps=implied_deps,
                                      pkg=pkg)
 
-@runonce
 @conf
 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
                          checkfunctions=None, headers=None, checkcode=None,
@@ -141,11 +130,34 @@
     this first tries via pkg-config, then if that fails
     tries by testing for a specified function in the specified lib
     '''
-    if conf.LIB_MUST_BE_BUNDLED(libname):
-        return False
+    # We always do a logic validation of 'onlyif' first
+    missing = []
+    if onlyif:
+        for l in TO_LIST(onlyif):
+            f = 'FOUND_SYSTEMLIB_%s' % l
+            if not f in conf.env:
+                Logs.error('ERROR: CHECK_BUNDLED_SYSTEM(%s) - ' % (libname) +
+                           'missing prerequisite check for ' +
+                           'system library %s, onlyif=%r' % (l, onlyif))
+                sys.exit(1)
+            if not conf.env[f]:
+                missing.append(l)
     found = 'FOUND_SYSTEMLIB_%s' % libname
     if found in conf.env:
         return conf.env[found]
+    if conf.LIB_MUST_BE_BUNDLED(libname):
+        conf.env[found] = False
+        return False
+
+    # see if the library should only use a system version if another dependent
+    # system version is found. That prevents possible use of mixed library
+    # versions
+    if missing:
+        if not conf.LIB_MAY_BE_BUNDLED(libname):
+            Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
+            sys.exit(1)
+        conf.env[found] = False
+        return False
 
     def check_functions_headers_code():
         '''helper function for CHECK_BUNDLED_SYSTEM'''
@@ -166,19 +178,6 @@
                 return False
         return True
 
-
-    # see if the library should only use a system version if another dependent
-    # system version is found. That prevents possible use of mixed library
-    # versions
-    if onlyif:
-        missing = conf.CHECK_PREREQUISITES(onlyif)
-        if missing:
-            if not conf.LIB_MAY_BE_BUNDLED(libname):
-                Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
-                sys.exit(1)
-            conf.env[found] = False
-            return False
-
     minversion = minimum_library_version(conf, libname, minversion)
 
     msg = 'Checking for system %s' % libname
@@ -190,7 +189,7 @@
         pkg = libname
 
     # try pkgconfig first
-    if (conf.check_cfg(package=pkg,
+    if (conf.CHECK_CFG(package=pkg,
                       args='"%s >= %s" --cflags --libs' % (pkg, minversion),
                       msg=msg, uselib_store=uselib_store) and
         check_functions_headers_code()):
@@ -218,7 +217,6 @@
 def tuplize_version(version):
     return tuple([int(x) for x in version.split(".")])
 
-@runonce
 @conf
 def CHECK_BUNDLED_SYSTEM_PYTHON(conf, libname, modulename, minversion='0.0.0'):
     '''check if a python module is available on the system and
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_conftests.py tevent-0.9.28/buildtools/wafsamba/samba_conftests.py
--- tevent-0.9.25/buildtools/wafsamba/samba_conftests.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_conftests.py	2016-02-26 03:24:44.000000000 +0000
@@ -2,10 +2,9 @@
 # to test for commonly needed configuration options
 
 import os, shutil, re
-import Build, Configure, Utils
+import Build, Configure, Utils, Options, Logs
 from Configure import conf
-import config_c
-from samba_utils import *
+from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH
 
 
 def add_option(self, *k, **kw):
@@ -197,7 +196,7 @@
     return v * 2;
 }
 '''
-    return conf.check(features='cc cshlib',vnum="1",fragment=snip,msg=msg)
+    return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg, mandatory=False)
 
 @conf
 def CHECK_NEED_LC(conf, msg):
@@ -216,9 +215,7 @@
 
     os.makedirs(subdir)
 
-    dest = open(os.path.join(subdir, 'liblc1.c'), 'w')
-    dest.write('#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
-    dest.close()
+    Utils.writef(os.path.join(subdir, 'liblc1.c'), '#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
 
     bld = Build.BuildContext()
     bld.log = conf.log
@@ -229,7 +226,7 @@
 
     bld.rescan(bld.srcnode)
 
-    bld(features='cc cshlib',
+    bld(features='c cshlib',
         source='liblctest/liblc1.c',
         ldflags=conf.env['EXTRA_LDFLAGS'],
         target='liblc',
@@ -249,9 +246,6 @@
     '''check if we need -undefined dynamic_lookup'''
 
     dir = find_config_dir(conf)
-
-    env = conf.env
-
     snip = '''
 #include <Python.h>
 #include <crt_externs.h>
@@ -264,7 +258,7 @@
     ldb_module = PyImport_ImportModule("ldb");
     return v * 2;
 }'''
-    return conf.check(features='cc cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
+    return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg, mandatory=False)
 
 # this one is quite complex, and should probably be broken up
 # into several parts. I'd quite like to create a set of CHECK_COMPOUND()
@@ -291,13 +285,8 @@
 
     os.makedirs(subdir)
 
-    dest = open(os.path.join(subdir, 'lib1.c'), 'w')
-    dest.write('int lib_func(void) { return 42; }\n')
-    dest.close()
-
-    dest = open(os.path.join(dir, 'main.c'), 'w')
-    dest.write('int main(void) {return !(lib_func() == 42);}\n')
-    dest.close()
+    Utils.writef(os.path.join(subdir, 'lib1.c'), 'int lib_func(void) { return 42; }\n')
+    Utils.writef(os.path.join(dir, 'main.c'), 'int main(void) {return !(lib_func() == 42);}\n')
 
     bld = Build.BuildContext()
     bld.log = conf.log
@@ -311,17 +300,15 @@
     ldflags = []
     if version_script:
         ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
-        dest = open(os.path.join(dir,'vscript'), 'w')
-        dest.write('TEST_1.0A2 { global: *; };\n')
-        dest.close()
+        Utils.writef(os.path.join(dir,'vscript'), 'TEST_1.0A2 { global: *; };\n')
 
-    bld(features='cc cshlib',
+    bld(features='c cshlib',
         source='libdir/lib1.c',
         target='libdir/lib1',
         ldflags=ldflags,
         name='lib1')
 
-    o = bld(features='cc cprogram',
+    o = bld(features='c cprogram',
             source='main.c',
             target='prog1',
             uselib_local='lib1')
@@ -383,15 +370,13 @@
     if not os.path.exists(bdir):
         os.makedirs(bdir)
 
-    dest = open(os.path.join(bdir, 'Makefile.PL'), 'w')
-    dest.write("""
+    Utils.writef(os.path.join(bdir, 'Makefile.PL'), """
 use ExtUtils::MakeMaker;
 WriteMakefile(
     'NAME'    => 'WafTest',
     'EXE_FILES' => [ 'WafTest' ]
 );
 """)
-    dest.close()
     back = os.path.abspath('.')
     os.chdir(bdir)
     proc = Utils.pproc.Popen(['perl', 'Makefile.PL'],
@@ -406,9 +391,7 @@
         return
 
     if section:
-        f = open(os.path.join(bdir,'Makefile'), 'r')
-        man = f.read()
-        f.close()
+        man = Utils.readf(os.path.join(bdir,'Makefile'))
         m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
         if not m:
             conf.check_message_2('not found', color='YELLOW')
@@ -537,53 +520,3 @@
 
     conf.env.STANDARD_LIBPATH = dirlist
 
-
-waf_config_c_parse_flags = config_c.parse_flags;
-def samba_config_c_parse_flags(line1, uselib, env):
-    #
-    # We do a special treatment of the rpath components
-    # in the linkflags line, because currently the upstream
-    # parse_flags function is incomplete with respect to
-    # treatment of the rpath. The remainder of the linkflags
-    # line is later passed to the original funcion.
-    #
-    lst1 = shlex.split(line1)
-    lst2 = []
-    while lst1:
-        x = lst1.pop(0)
-
-        #
-        # NOTE on special treatment of -Wl,-R and -Wl,-rpath:
-        #
-        # It is important to not put a library provided RPATH
-        # into the LINKFLAGS but in the RPATH instead, since
-        # the provided LINKFLAGS get prepended to our own internal
-        # RPATH later, and hence can potentially lead to linking
-        # in too old versions of our internal libs.
-        #
-        # We do this filtering here on our own because of some
-        # bugs in the real parse_flags() function.
-        #
-        if x == '-Wl,-rpath' or x == '-Wl,-R':
-            x = lst1.pop(0)
-            if x.startswith('-Wl,'):
-                rpath = x[4:]
-            else:
-                rpath = x
-        elif x.startswith('-Wl,-R,'):
-            rpath = x[7:]
-        elif x.startswith('-Wl,-R'):
-            rpath = x[6:]
-        elif x.startswith('-Wl,-rpath,'):
-            rpath = x[11:]
-        else:
-            lst2.append(x)
-            continue
-
-        env.append_value('RPATH_' + uselib, rpath)
-
-    line2 = ' '.join(lst2)
-    waf_config_c_parse_flags(line2, uselib, env)
-
-    return
-config_c.parse_flags = samba_config_c_parse_flags
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_cross.py tevent-0.9.28/buildtools/wafsamba/samba_cross.py
--- tevent-0.9.25/buildtools/wafsamba/samba_cross.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_cross.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,8 +1,8 @@
 # functions for handling cross-compilation
 
-import Utils, Logs, sys, os, Options, re
+import os, sys, re, shlex
+import Utils, Logs, Options
 from Configure import conf
-import shlex
 
 real_Popen = None
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_deps.py tevent-0.9.28/buildtools/wafsamba/samba_deps.py
--- tevent-0.9.25/buildtools/wafsamba/samba_deps.py	2014-11-29 10:30:57.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_deps.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,9 +1,14 @@
 # Samba automatic dependency handling and project rules
 
-import Build, os, sys, re, Environment, Logs, time
-from samba_utils import *
-from samba_autoconf import *
+import os, sys, re, time
+
+import Build, Environment, Options, Logs, Utils
+from Logs import debug
+from Configure import conf
+
 from samba_bundled import BUILTIN_LIBRARY
+from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list, os_path_relpath
+from samba_autoconf import library_flags
 
 @conf
 def ADD_GLOBAL_DEPENDENCY(ctx, dep):
@@ -47,7 +52,7 @@
         #    module_name    = rpc_epmapper (a module within the dcerpc_server subsystem)
         #    module         = rpc_epmapper (a module object within the dcerpc_server subsystem)
 
-        subsystem = bld.name_to_obj(subsystem_name, bld.env)
+        subsystem = bld.get_tgen_by_name(subsystem_name)
         bld.ASSERT(subsystem is not None, "Unable to find subsystem %s" % subsystem_name)
         for d in subsystem_list[subsystem_name]:
             module_name = d['TARGET']
@@ -101,7 +106,7 @@
         self.uselib = list(self.final_syslibs)
         self.uselib.extend(list(self.direct_syslibs))
         for lib in self.final_libs:
-            t = self.bld.name_to_obj(lib, self.bld.env)
+            t = self.bld.get_tgen_by_name(lib)
             self.uselib.extend(list(t.final_syslibs))
         self.uselib = unique_list(self.uselib)
 
@@ -150,7 +155,7 @@
     inc_abs = []
 
     for d in inc_deps:
-        t = bld.name_to_obj(d, bld.env)
+        t = bld.get_tgen_by_name(d)
         bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
         inclist = getattr(t, 'samba_includes_extended', [])[:]
         if getattr(t, 'local_include', True):
@@ -214,6 +219,9 @@
     if m is not None:
         modules.append(m)
 
+    if 'pyembed' in self.features:
+        return
+
     sentinel = getattr(self, 'init_function_sentinel', 'NULL')
 
     targets    = LOCAL_CACHE(bld, 'TARGET_TYPE')
@@ -252,15 +260,10 @@
 
 
 def check_duplicate_sources(bld, tgt_list):
-    '''see if we are compiling the same source file more than once
-       without an allow_duplicates attribute'''
+    '''see if we are compiling the same source file more than once'''
 
     debug('deps: checking for duplicate sources')
-
     targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
-    ret = True
-
-    global tstart
 
     for t in tgt_list:
         source_list = TO_LIST(getattr(t, 'source', ''))
@@ -278,11 +281,10 @@
 
     # build a list of targets that each source file is part of
     for t in tgt_list:
-        sources = []
         if not targets[t.sname] in [ 'LIBRARY', 'BINARY', 'PYTHON' ]:
             continue
         for obj in t.add_objects:
-            t2 = t.bld.name_to_obj(obj, bld.env)
+            t2 = t.bld.get_tgen_by_name(obj)
             source_set = getattr(t2, 'samba_source_set', set())
             for s in source_set:
                 if not s in subsystems:
@@ -298,24 +300,7 @@
             if len(subsystems[s][tname]) > 1:
                 raise Utils.WafError("ERROR: source %s is in more than one subsystem of target '%s': %s" % (s, tname, subsystems[s][tname]))
 
-    return ret
-
-
-def check_orphaned_targets(bld, tgt_list):
-    '''check if any build targets are orphaned'''
-
-    target_dict = LOCAL_CACHE(bld, 'TARGET_TYPE')
-
-    debug('deps: checking for orphaned targets')
-
-    for t in tgt_list:
-        if getattr(t, 'samba_used', False):
-            continue
-        type = target_dict[t.sname]
-        if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']:
-            if re.search('^PIDL_', t.sname) is None:
-                Logs.warn("Target %s of type %s is unused by any other target" % (t.sname, type))
-
+    return True
 
 def check_group_ordering(bld, tgt_list):
     '''see if we have any dependencies that violate the group ordering
@@ -346,7 +331,7 @@
     for t in tgt_list:
         tdeps = getattr(t, 'add_objects', []) + getattr(t, 'uselib_local', [])
         for d in tdeps:
-            t2 = bld.name_to_obj(d, bld.env)
+            t2 = bld.get_tgen_by_name(d)
             if t2 is None:
                 continue
             map1 = grp_map[t.samba_group]
@@ -358,7 +343,7 @@
                 ret = False
 
     return ret
-
+Build.BuildContext.check_group_ordering = check_group_ordering
 
 def show_final_deps(bld, tgt_list):
     '''show the final dependencies for all targets'''
@@ -429,7 +414,7 @@
     global_deps = bld.env.GLOBAL_DEPENDENCIES
     global_deps_exclude = set()
     for dep in global_deps:
-        t = bld.name_to_obj(dep, bld.env)
+        t = bld.get_tgen_by_name(dep)
         for d in t.samba_deps:
             # prevent loops from the global dependencies list
             global_deps_exclude.add(d)
@@ -469,7 +454,7 @@
                                 implied, t.sname, targets[implied]))
                             sys.exit(1)
                 continue
-            t2 = bld.name_to_obj(d, bld.env)
+            t2 = bld.get_tgen_by_name(d)
             if t2 is None:
                 Logs.error("no task %s of type %s in %s" % (d, targets[d], t.sname))
                 sys.exit(1)
@@ -507,7 +492,7 @@
             dependency_loop(loops, t, obj)
             continue
         chain.add(obj)
-        t2 = bld.name_to_obj(obj, bld.env)
+        t2 = bld.get_tgen_by_name(obj)
         r2 = indirect_libs(bld, t2, chain, loops)
         chain.remove(obj)
         ret = ret.union(t2.direct_libs)
@@ -518,7 +503,7 @@
             dependency_loop(loops, t, obj)
             continue
         chain.add(obj)
-        t2 = bld.name_to_obj(obj, bld.env)
+        t2 = bld.get_tgen_by_name(obj)
         r2 = indirect_libs(bld, t2, chain, loops)
         chain.remove(obj)
         ret = ret.union(t2.direct_libs)
@@ -545,7 +530,7 @@
             dependency_loop(loops, t, lib)
             continue
         chain.add(lib)
-        t2 = bld.name_to_obj(lib, bld.env)
+        t2 = bld.get_tgen_by_name(lib)
         r2 = indirect_objects(bld, t2, chain, loops)
         chain.remove(lib)
         ret = ret.union(t2.direct_objects)
@@ -573,7 +558,7 @@
     for lib in t.final_libs:
         if lib in chain:
             continue
-        t2 = bld.name_to_obj(lib, bld.env)
+        t2 = bld.get_tgen_by_name(lib)
         chain.add(lib)
         r2 = extended_objects(bld, t2, chain)
         chain.remove(lib)
@@ -601,7 +586,7 @@
             dependency_loop(inc_loops, t, obj)
             continue
         chain.add(obj)
-        t2 = bld.name_to_obj(obj, bld.env)
+        t2 = bld.get_tgen_by_name(obj)
         r2 = includes_objects(bld, t2, chain, inc_loops)
         chain.remove(obj)
         ret = ret.union(t2.direct_objects)
@@ -612,7 +597,7 @@
             dependency_loop(inc_loops, t, lib)
             continue
         chain.add(lib)
-        t2 = bld.name_to_obj(lib, bld.env)
+        t2 = bld.get_tgen_by_name(lib)
         if t2 is None:
             targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
             Logs.error('Target %s of type %s not found in direct_libs for %s' % (
@@ -665,7 +650,7 @@
 
     # expand indirect subsystem and library loops
     for loop in loops.copy():
-        t = bld.name_to_obj(loop, bld.env)
+        t = bld.get_tgen_by_name(loop)
         if t.samba_type in ['SUBSYSTEM']:
             loops[loop] = loops[loop].union(t.indirect_objects)
             loops[loop] = loops[loop].union(t.direct_objects)
@@ -677,7 +662,7 @@
 
     # expand indirect includes loops
     for loop in inc_loops.copy():
-        t = bld.name_to_obj(loop, bld.env)
+        t = bld.get_tgen_by_name(loop)
         inc_loops[loop] = inc_loops[loop].union(t.includes_objects)
         if loop in inc_loops[loop]:
             inc_loops[loop].remove(loop)
@@ -723,7 +708,7 @@
             # if we will indirectly link to a target then we don't need it
             new = t.final_objects.copy()
             for l in t.final_libs:
-                t2 = bld.name_to_obj(l, bld.env)
+                t2 = bld.get_tgen_by_name(l)
                 t2_obj = extended_objects(bld, t2, set())
                 dup = new.intersection(t2_obj)
                 if t.sname in rely_on:
@@ -743,7 +728,7 @@
 
     # add back in any objects that were relied upon by the reduction rules
     for r in rely_on:
-        t = bld.name_to_obj(r, bld.env)
+        t = bld.get_tgen_by_name(r)
         t.final_objects = t.final_objects.union(rely_on[r])
 
     return True
@@ -752,7 +737,7 @@
 def show_library_loop(bld, lib1, lib2, path, seen):
     '''show the detailed path of a library loop between lib1 and lib2'''
 
-    t = bld.name_to_obj(lib1, bld.env)
+    t = bld.get_tgen_by_name(lib1)
     if not lib2 in getattr(t, 'final_libs', set()):
         return
 
@@ -791,7 +776,7 @@
             # replace lib deps with objlist deps
             for l in t.final_libs:
                 objname = l + '.objlist'
-                t2 = bld.name_to_obj(objname, bld.env)
+                t2 = bld.get_tgen_by_name(objname)
                 if t2 is None:
                     Logs.error('ERROR: subsystem %s not found' % objname)
                     sys.exit(1)
@@ -807,7 +792,7 @@
                             objname = module_name
                         else:
                             continue
-                        t2 = bld.name_to_obj(objname, bld.env)
+                        t2 = bld.get_tgen_by_name(objname)
                         if t2 is None:
                             Logs.error('ERROR: subsystem %s not found' % objname)
                             sys.exit(1)
@@ -819,7 +804,7 @@
     for t in tgt_list:
         if t.samba_type in ['LIBRARY', 'PYTHON']:
             for l in t.final_libs.copy():
-                t2 = bld.name_to_obj(l, bld.env)
+                t2 = bld.get_tgen_by_name(l)
                 if t.sname in t2.final_libs:
                     if getattr(bld.env, "ALLOW_CIRCULAR_LIB_DEPENDENCIES", False):
                         # we could break this in either direction. If one of the libraries
@@ -853,7 +838,7 @@
                         diff.remove(t.sname)
                     # make sure we don't recreate the loop again!
                     for d in diff.copy():
-                        t2 = bld.name_to_obj(d, bld.env)
+                        t2 = bld.get_tgen_by_name(d)
                         if t2.samba_type == 'LIBRARY':
                             if t.sname in t2.final_libs:
                                 debug('deps: removing expansion %s from %s', d, t.sname)
@@ -878,12 +863,12 @@
             continue
         syslibs = set()
         for d in t.final_objects:
-            t2 = bld.name_to_obj(d, bld.env)
+            t2 = bld.get_tgen_by_name(d)
             syslibs = syslibs.union(t2.direct_syslibs)
         # this adds the indirect syslibs as well, which may not be needed
         # depending on the linker flags
         for d in t.final_libs:
-            t2 = bld.name_to_obj(d, bld.env)
+            t2 = bld.get_tgen_by_name(d)
             syslibs = syslibs.union(t2.direct_syslibs)
         t.final_syslibs = syslibs
 
@@ -893,7 +878,7 @@
     for t in tgt_list:
         if t.samba_type in ['LIBRARY', 'PYTHON']:
             for l in t.final_libs.copy():
-                t2 = bld.name_to_obj(l, bld.env)
+                t2 = bld.get_tgen_by_name(l)
                 if t.sname in t2.final_libs:
                     Logs.error('ERROR: Unresolved library loop %s from %s' % (t.sname, t2.sname))
                     lib_loop_error = True
@@ -909,7 +894,7 @@
     if target in seen:
         return
 
-    t = bld.name_to_obj(target, bld.env)
+    t = bld.get_tgen_by_name(target)
     if t is None:
         Logs.error("ERROR: Unable to find target '%s'" % target)
         sys.exit(1)
@@ -938,7 +923,7 @@
         if not targets[t.sname] in [ 'LIBRARY', 'PYTHON' ]:
             continue
         for n in getattr(t, 'final_objects', set()):
-            t2 = bld.name_to_obj(n, bld.env)
+            t2 = bld.get_tgen_by_name(n)
             if not n in used_by:
                 used_by[n] = set()
             used_by[n].add(t.sname)
@@ -964,7 +949,8 @@
 savedeps_inputs  = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags',
                     'source', 'grouping_library', 'samba_ldflags', 'allow_undefined_symbols',
                     'use_global_deps', 'global_include' ]
-savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags', 'ldflags', 'samba_deps_extended']
+savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes',
+                    'ccflags', 'ldflags', 'samba_deps_extended', 'final_libs']
 savedeps_outenv  = ['INC_PATHS']
 savedeps_envvars = ['NONSHARED_BINARIES', 'GLOBAL_DEPENDENCIES', 'EXTRA_CFLAGS', 'EXTRA_LDFLAGS', 'EXTRA_INCLUDES' ]
 savedeps_caches  = ['GLOBAL_DEPENDENCIES', 'TARGET_TYPE', 'INIT_FUNCTIONS', 'SYSLIB_DEPS']
@@ -1148,15 +1134,13 @@
 
     debug('deps: project rules stage1 completed')
 
-    #check_orphaned_targets(bld, tgt_list)
-
     if not check_duplicate_sources(bld, tgt_list):
         Logs.error("Duplicate sources present - aborting")
         sys.exit(1)
 
     debug("deps: check_duplicate_sources: %f" % (time.clock() - tstart))
 
-    if not check_group_ordering(bld, tgt_list):
+    if not bld.check_group_ordering(tgt_list):
         Logs.error("Bad group ordering - aborting")
         sys.exit(1)
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_dist.py tevent-0.9.28/buildtools/wafsamba/samba_dist.py
--- tevent-0.9.25/buildtools/wafsamba/samba_dist.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_dist.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,8 +1,10 @@
 # customised version of 'waf dist' for Samba tools
 # uses git ls-files to get file lists
 
-import Utils, os, sys, tarfile, stat, Scripting, Logs, Options
-from samba_utils import *
+import os, sys, tarfile
+import Utils, Scripting, Logs, Options
+from Configure import conf
+from samba_utils import os_path_relpath
 
 dist_dirs = None
 dist_files = None
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_headers.py tevent-0.9.28/buildtools/wafsamba/samba_headers.py
--- tevent-0.9.25/buildtools/wafsamba/samba_headers.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_headers.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,7 +1,8 @@
 # specialist handling of header files for Samba
 
-import Build, re, Task, TaskGen, shutil, sys, Logs
-from samba_utils import *
+import os, re, sys, fnmatch
+import Build, Logs, Utils
+from samba_utils import TO_LIST, os_path_relpath
 
 
 def header_install_path(header, header_path):
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_install.py tevent-0.9.28/buildtools/wafsamba/samba_install.py
--- tevent-0.9.25/buildtools/wafsamba/samba_install.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_install.py	2016-02-26 03:24:44.000000000 +0000
@@ -3,9 +3,10 @@
 # with all the configure options that affect rpath and shared
 # library use
 
-import Options
+import os
+import Utils
 from TaskGen import feature, before, after
-from samba_utils import *
+from samba_utils import LIB_PATH, MODE_755, install_rpath, build_rpath
 
 @feature('install_bin')
 @after('apply_core')
@@ -18,7 +19,7 @@
     install_ldflags = install_rpath(self)
     build_ldflags   = build_rpath(bld)
 
-    if not Options.is_install:
+    if not self.bld.is_install:
         # just need to set rpath if we are not installing
         self.env.RPATH = build_ldflags
         return
@@ -67,7 +68,7 @@
         install_ldflags = install_rpath(self)
         build_ldflags   = build_rpath(bld)
 
-        if not Options.is_install or not getattr(self, 'samba_install', True):
+        if not self.bld.is_install or not getattr(self, 'samba_install', True):
             # just need to set the build rpath if we are not installing
             self.env.RPATH = build_ldflags
             return
@@ -91,6 +92,7 @@
             t = self.clone(self.env)
             t.posted = False
             t.target += '.inst'
+            t.name = self.name + '.inst'
             self.env.RPATH = build_ldflags
         else:
             t = self
@@ -224,7 +226,6 @@
     if self.target.endswith('.inst'):
         return
 
-    blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
     if not self.link_task.outputs or not self.link_task.outputs[0]:
         raise Utils.WafError('no outputs found for %s in symlink_bin' % self.name)
     binpath = self.link_task.outputs[0].abspath(self.env)
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_optimisation.py tevent-0.9.28/buildtools/wafsamba/samba_optimisation.py
--- tevent-0.9.25/buildtools/wafsamba/samba_optimisation.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_optimisation.py	2016-02-26 03:24:44.000000000 +0000
@@ -11,7 +11,7 @@
 from TaskGen import feature, after, before
 import preproc
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
 def apply_incpaths(self):
     lst = []
@@ -59,7 +59,7 @@
         if node:
             self.env.append_value('INC_PATHS', node)
 
-@feature('cc')
+@feature('c', 'cc')
 @after('apply_incpaths')
 def apply_obj_vars_cc(self):
     """after apply_incpaths for INC_PATHS"""
@@ -165,7 +165,7 @@
     try:
         return cache[name]
     except KeyError:
-        ret = cache[name] = 'cstaticlib' in self.bld.name_to_obj(name, self.env).features
+        ret = cache[name] = 'cstaticlib' in self.bld.get_tgen_by_name(name).features
         return ret
 TaskGen.task_gen.is_this_a_static_lib = is_this_a_static_lib
 
@@ -187,7 +187,7 @@
         return ret
 TaskGen.task_gen.shared_ancestors = shared_ancestors
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('apply_link', 'init_cc', 'init_cxx', 'apply_core')
 def apply_lib_vars(self):
     """after apply_link because of 'link_task'
@@ -215,7 +215,7 @@
         if lib_name in seen:
             continue
 
-        y = self.name_to_obj(lib_name)
+        y = self.get_tgen_by_name(lib_name)
         if not y:
             raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name))
         y.post()
@@ -266,24 +266,4 @@
             if val:
                 self.env.append_value(v, val)
 
-@feature('cprogram', 'cshlib', 'cstaticlib')
-@after('apply_lib_vars')
-@before('apply_obj_vars')
-def samba_before_apply_obj_vars(self):
-    """before apply_obj_vars for uselib, this removes the standard pathes"""
-
-    def is_standard_libpath(env, path):
-        for _path in env.STANDARD_LIBPATH:
-            if _path == os.path.normpath(path):
-                return True
-        return False
-
-    v = self.env
-
-    for i in v['RPATH']:
-        if is_standard_libpath(v, i):
-            v['RPATH'].remove(i)
-
-    for i in v['LIBPATH']:
-        if is_standard_libpath(v, i):
-            v['LIBPATH'].remove(i)
+
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_patterns.py tevent-0.9.28/buildtools/wafsamba/samba_patterns.py
--- tevent-0.9.25/buildtools/wafsamba/samba_patterns.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_patterns.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,21 +1,16 @@
 # a waf tool to add extension based build patterns for Samba
 
-import Task
-from TaskGen import extension
-from samba_utils import *
+import Build
 from wafsamba import samba_version_file
 
 def write_version_header(task):
     '''print version.h contents'''
     src = task.inputs[0].srcpath(task.env)
-    tgt = task.outputs[0].bldpath(task.env)
 
-    version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.env.is_install)
+    version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.generator.bld.is_install)
     string = str(version)
 
-    f = open(tgt, 'w')
-    s = f.write(string)
-    f.close()
+    task.outputs[0].write(string)
     return 0
 
 
@@ -30,7 +25,6 @@
                             source= 'VERSION',
                             target=target,
                             always=bld.is_install)
-    t.env.is_install = bld.is_install
 Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
 
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_perl.py tevent-0.9.28/buildtools/wafsamba/samba_perl.py
--- tevent-0.9.25/buildtools/wafsamba/samba_perl.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_perl.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,17 +1,10 @@
-import Build
-from samba_utils import *
+import Utils
 from Configure import conf
 
 done = {}
 
 @conf
 def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)):
-    #
-    # TODO: use the @runonce mechanism for this.
-    # The problem is that @runonce currently does
-    # not seem to work together with @conf...
-    # So @runonce (and/or) @conf needs fixing.
-    #
     if "done" in done:
         return
     done["done"] = True
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_pidl.py tevent-0.9.28/buildtools/wafsamba/samba_pidl.py
--- tevent-0.9.25/buildtools/wafsamba/samba_pidl.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_pidl.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,8 +1,9 @@
 # waf build tool for building IDL files with pidl
 
-from TaskGen import before
-import Build, os, sys, Logs
-from samba_utils import *
+import os
+import Build
+from TaskGen import feature, before
+from samba_utils import SET_TARGET_TYPE, TO_LIST, LOCAL_CACHE
 
 def SAMBA_PIDL(bld, pname, source,
                options='',
@@ -112,13 +113,12 @@
 
 #################################################################
 # the rule for generating the NDR tables
-from TaskGen import feature, before
 @feature('collect')
 @before('exec_rule')
 def collect(self):
     pidl_headers = LOCAL_CACHE(self.bld, 'PIDL_HEADERS')
     for (name, hd) in pidl_headers.items():
-        y = self.bld.name_to_obj(name, self.env)
+        y = self.bld.get_tgen_by_name(name)
         self.bld.ASSERT(y is not None, 'Failed to find PIDL header %s' % name)
         y.post()
         for node in hd:
@@ -128,7 +128,6 @@
 
 def SAMBA_PIDL_TABLES(bld, name, target):
     '''generate the pidl NDR tables file'''
-    headers = bld.env.PIDL_HEADERS
     bld.SET_BUILD_GROUP('main')
     t = bld(
             features = 'collect',
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_python.py tevent-0.9.28/buildtools/wafsamba/samba_python.py
--- tevent-0.9.25/buildtools/wafsamba/samba_python.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_python.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,14 +1,16 @@
 # waf build tool for building IDL files with pidl
 
-import Build
-from samba_utils import *
-from samba_autoconf import *
-
+import os
+import Build, Logs, Utils, Configure
 from Configure import conf
 
 @conf
 def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
     # enable tool to build python extensions
+    if conf.env.HAVE_PYTHON_H:
+        conf.check_python_version(version)
+        return
+
     interpreters = []
 
     if conf.env['EXTRA_PYTHON']:
@@ -21,7 +23,7 @@
         try:
             conf.check_python_version((3, 3, 0))
         except Exception:
-            warn('extra-python needs to be Python 3.3 or later')
+            Logs.warn('extra-python needs to be Python 3.3 or later')
             raise
         interpreters.append(conf.env['PYTHON'])
         conf.setenv('default')
@@ -55,9 +57,18 @@
     else:
         conf.msg("python headers", "using cache")
 
+    # we don't want PYTHONDIR in config.h, as otherwise changing
+    # --prefix causes a complete rebuild
+    del(conf.env.defines['PYTHONDIR'])
+    del(conf.env.defines['PYTHONARCHDIR'])
 
 def _check_python_headers(conf, mandatory):
-    conf.check_python_headers(mandatory=mandatory)
+    try:
+        Configure.ConfigurationError
+        conf.check_python_headers(mandatory=mandatory)
+    except Configure.ConfigurationError:
+        if mandatory:
+             raise
 
     if conf.env['PYTHON_VERSION'] > '3':
         abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0]
@@ -86,7 +97,18 @@
     # when we support static python modules we'll need to gather
     # the list from all the SAMBA_PYTHON() targets
     if init_function_sentinel is not None:
-        cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
+        cflags += ' -DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
+
+    # From https://docs.python.org/2/c-api/arg.html:
+    # Starting with Python 2.5 the type of the length argument to
+    # PyArg_ParseTuple(), PyArg_ParseTupleAndKeywords() and PyArg_Parse()
+    # can be controlled by defining the macro PY_SSIZE_T_CLEAN before
+    # including Python.h. If the macro is defined, length is a Py_ssize_t
+    # rather than an int.
+
+    # Because <Python.h> if often included before includes.h/config.h
+    # This must be in the -D compiler options
+    cflags += ' -DPY_SSIZE_T_CLEAN=1'
 
     source = bld.EXPAND_VARIABLES(source, vars=vars)
 
@@ -109,7 +131,6 @@
                       target_type='PYTHON',
                       install_path='${PYTHONARCHDIR}',
                       allow_undefined_symbols=True,
-                      allow_warnings=True,
                       install=install,
                       enabled=enabled)
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_third_party.py tevent-0.9.28/buildtools/wafsamba/samba_third_party.py
--- tevent-0.9.25/buildtools/wafsamba/samba_third_party.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_third_party.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,8 +1,8 @@
 # functions to support third party libraries
 
+import os
+import Utils, Build
 from Configure import conf
-import sys, Logs, os
-from samba_bundled import *
 
 @conf
 def CHECK_FOR_THIRD_PARTY(conf):
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_utils.py tevent-0.9.28/buildtools/wafsamba/samba_utils.py
--- tevent-0.9.25/buildtools/wafsamba/samba_utils.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_utils.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,11 +1,11 @@
 # a waf tool to add autoconf-like macros to the configure section
 # and for SAMBA_ macros for building libraries, binaries etc
 
-import Build, os, sys, Options, Utils, Task, re, fnmatch, Logs
-from TaskGen import feature, before
+import os, sys, re, fnmatch, shlex
+import Build, Options, Utils, Task, Logs, Configure
+from TaskGen import feature, before, after
 from Configure import conf, ConfigurationContext
 from Logs import debug
-import shlex
 
 # TODO: make this a --option
 LIB_PATH="shared"
@@ -35,22 +35,6 @@
     return cache[target]
 
 
-######################################################
-# this is used as a decorator to make functions only
-# run once. Based on the idea from
-# http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values
-def runonce(function):
-    runonce_ret = {}
-    def runonce_wrapper(*args):
-        if args in runonce_ret:
-            return runonce_ret[args]
-        else:
-            ret = function(*args)
-            runonce_ret[args] = ret
-            return ret
-    return runonce_wrapper
-
-
 def ADD_LD_LIBRARY_PATH(path):
     '''add something to LD_LIBRARY_PATH'''
     if 'LD_LIBRARY_PATH' in os.environ:
@@ -66,7 +50,7 @@
 def needs_private_lib(bld, target):
     '''return True if a target links to a private library'''
     for lib in getattr(target, "final_libs", []):
-        t = bld.name_to_obj(lib, bld.env)
+        t = bld.get_tgen_by_name(lib)
         if t and getattr(t, 'private_library', False):
             return True
     return False
@@ -135,28 +119,6 @@
         if t not in d1:
             d1[t] = d2[t]
 
-
-def exec_command(self, cmd, **kw):
-    '''this overrides the 'waf -v' debug output to be in a nice
-    unix like format instead of a python list.
-    Thanks to ita on #waf for this'''
-    import Utils, Logs
-    _cmd = cmd
-    if isinstance(cmd, list):
-        _cmd = ' '.join(cmd)
-    debug('runner: %s' % _cmd)
-    if self.log:
-        self.log.write('%s\n' % cmd)
-        kw['log'] = self.log
-    try:
-        if not kw.get('cwd', None):
-            kw['cwd'] = self.cwd
-    except AttributeError:
-        self.cwd = kw['cwd'] = self.bldnode.abspath()
-    return Utils.exec_command(cmd, **kw)
-Build.BuildContext.exec_command = exec_command
-
-
 def ADD_COMMAND(opt, name, function):
     '''add a new top level command to waf'''
     Utils.g_module.__dict__[name] = function
@@ -164,7 +126,7 @@
 Options.Handler.ADD_COMMAND = ADD_COMMAND
 
 
-@feature('cc', 'cshlib', 'cprogram')
+@feature('c', 'cc', 'cshlib', 'cprogram')
 @before('apply_core','exec_rule')
 def process_depends_on(self):
     '''The new depends_on attribute for build rules
@@ -173,7 +135,7 @@
     if getattr(self , 'depends_on', None):
         lst = self.to_list(self.depends_on)
         for x in lst:
-            y = self.bld.name_to_obj(x, self.env)
+            y = self.bld.get_tgen_by_name(x)
             self.bld.ASSERT(y is not None, "Failed to find dependency %s of %s" % (x, self.name))
             y.post()
             if getattr(y, 'more_includes', None):
@@ -386,7 +348,7 @@
     return -1
 
 
-def RUN_PYTHON_TESTS(testfiles, pythonpath=None):
+def RUN_PYTHON_TESTS(testfiles, pythonpath=None, extra_env=None):
     env = LOAD_ENVIRONMENT()
     if pythonpath is None:
         pythonpath = os.path.join(Utils.g_module.blddir, 'python')
@@ -394,6 +356,9 @@
     for interp in env.python_interpreters:
         for testfile in testfiles:
             cmd = "PYTHONPATH=%s %s %s" % (pythonpath, interp, testfile)
+            if extra_env:
+                for key, value in extra_env.items():
+                    cmd = "%s=%s %s" % (key, value, cmd)
             print('Running Python test with %s: %s' % (interp, testfile))
             ret = RUN_COMMAND(cmd)
             if ret:
@@ -644,7 +609,7 @@
         type = targets[tgt]
         if not type in ['SUBSYSTEM', 'MODULE', 'BINARY', 'LIBRARY', 'ASN1', 'PYTHON']:
             continue
-        t = bld.name_to_obj(tgt, bld.env)
+        t = bld.get_tgen_by_name(tgt)
         if t is None:
             Logs.error("Target %s of type %s has no task generator" % (tgt, type))
             sys.exit(1)
@@ -657,11 +622,10 @@
         You should have file named wscript_<stage>_rule in the current directory
         where stage is either 'configure' or 'build'
     '''
-    ctxclass = self.__class__.__name__
     stage = ''
-    if ctxclass == 'ConfigurationContext':
+    if isinstance(self, Configure.ConfigurationContext):
         stage = 'configure'
-    elif ctxclass == 'BuildContext':
+    elif isinstance(self, Build.BuildContext):
         stage = 'build'
     file_path = os.path.join(self.curdir, WSCRIPT_FILE+'_'+stage+'_'+rule)
     txt = load_file(file_path)
@@ -682,3 +646,26 @@
     return False
 
 Build.BuildContext.AD_DC_BUILD_IS_ENABLED = AD_DC_BUILD_IS_ENABLED
+
+@feature('cprogram', 'cshlib', 'cstaticlib')
+@after('apply_lib_vars')
+@before('apply_obj_vars')
+def samba_before_apply_obj_vars(self):
+    """before apply_obj_vars for uselib, this removes the standard paths"""
+
+    def is_standard_libpath(env, path):
+        for _path in env.STANDARD_LIBPATH:
+            if _path == os.path.normpath(path):
+                return True
+        return False
+
+    v = self.env
+
+    for i in v['RPATH']:
+        if is_standard_libpath(v, i):
+            v['RPATH'].remove(i)
+
+    for i in v['LIBPATH']:
+        if is_standard_libpath(v, i):
+            v['LIBPATH'].remove(i)
+
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_version.py tevent-0.9.28/buildtools/wafsamba/samba_version.py
--- tevent-0.9.25/buildtools/wafsamba/samba_version.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_version.py	2016-02-26 03:24:44.000000000 +0000
@@ -42,12 +42,10 @@
 
 def distversion_version_summary(path):
     #get version from .distversion file
-    f = open(path + '/.distversion', 'r')
     suffix = None
     fields = {}
 
-    for line in f:
-        line = line.strip()
+    for line in Utils.readf(path + '/.distversion').splitlines():
         if line == '':
             continue
         if line.startswith("#"):
@@ -64,7 +62,6 @@
         except:
             print("Failed to parse line %s from .distversion file." % (line))
             raise
-    f.close()
 
     if "COMMIT_TIME" in fields:
         fields["COMMIT_TIME"] = int(fields["COMMIT_TIME"])
diff -Nru tevent-0.9.25/buildtools/wafsamba/samba_wildcard.py tevent-0.9.28/buildtools/wafsamba/samba_wildcard.py
--- tevent-0.9.25/buildtools/wafsamba/samba_wildcard.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/samba_wildcard.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,9 +1,9 @@
 # based on playground/evil in the waf svn tree
 
-import os, datetime
-import Scripting, Utils, Options, Logs, Environment, fnmatch
-from Constants import *
-from samba_utils import *
+import os, datetime, fnmatch
+import Scripting, Utils, Options, Logs, Environment
+from Constants import SRCDIR, BLDDIR
+from samba_utils import LOCAL_CACHE, os_path_relpath
 
 def run_task(t, k):
     '''run a single build task'''
@@ -130,7 +130,6 @@
 
     Options.commands['install'] = False
     Options.commands['uninstall'] = False
-    Options.is_install = False
 
     bld.is_install = 0 # False
 
diff -Nru tevent-0.9.25/buildtools/wafsamba/symbols.py tevent-0.9.28/buildtools/wafsamba/symbols.py
--- tevent-0.9.25/buildtools/wafsamba/symbols.py	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/symbols.py	2016-02-26 03:24:44.000000000 +0000
@@ -1,9 +1,10 @@
 # a waf tool to extract symbols from object files or libraries
 # using nm, producing a set of exposed defined/undefined symbols
 
-import Utils, Build, subprocess, Logs, re
-from samba_wildcard import fake_build_environment
-from samba_utils import *
+import os, re, subprocess
+import Utils, Build, Options, Logs
+from Logs import debug
+from samba_utils import TO_LIST, LOCAL_CACHE, get_tgt_list, os_path_relpath
 
 # these are the data structures used in symbols.py:
 #
@@ -251,7 +252,7 @@
             bld.env.public_symbols[name] = t.public_symbols
         if t.samba_type == 'LIBRARY':
             for dep in t.add_objects:
-                t2 = bld.name_to_obj(dep, bld.env)
+                t2 = bld.get_tgen_by_name(dep)
                 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
                 bld.env.public_symbols[name] = bld.env.public_symbols[name].union(t2.public_symbols)
 
@@ -264,7 +265,7 @@
             bld.env.used_symbols[name] = t.used_symbols
         if t.samba_type == 'LIBRARY':
             for dep in t.add_objects:
-                t2 = bld.name_to_obj(dep, bld.env)
+                t2 = bld.get_tgen_by_name(dep)
                 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
                 bld.env.used_symbols[name] = bld.env.used_symbols[name].union(t2.used_symbols)
 
@@ -362,7 +363,7 @@
             if targets[depname[0]] in [ 'SYSLIB' ]:
                 deps.add(depname[0])
                 continue
-            t2 = bld.name_to_obj(depname[0], bld.env)
+            t2 = bld.get_tgen_by_name(depname[0])
             if len(t2.in_library) != 1:
                 deps.add(depname[0])
                 continue
@@ -385,7 +386,7 @@
     for t in tgt_list:
         if t.samba_type in [ 'LIBRARY' ]:
             for obj in t.samba_deps_extended:
-                t2 = bld.name_to_obj(obj, bld.env)
+                t2 = bld.get_tgen_by_name(obj)
                 if t2 and t2.samba_type in [ 'SUBSYSTEM', 'ASN1' ]:
                     if not t.sname in t2.in_library:
                         t2.in_library.append(t.sname)
@@ -402,7 +403,7 @@
         Logs.warn("WARNING: Target '%s' in multiple libraries: %s" % (t.sname, t.in_library))
 
     for dep in t.autodeps:
-        t2 = bld.name_to_obj(dep, bld.env)
+        t2 = bld.get_tgen_by_name(dep)
         if t2 is None:
             continue
         for dep2 in t2.autodeps:
@@ -435,7 +436,7 @@
 def check_dependencies(bld, t):
     '''check for depenencies that should be changed'''
 
-    if bld.name_to_obj(t.sname + ".objlist", bld.env):
+    if bld.get_tgen_by_name(t.sname + ".objlist"):
         return
 
     targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
@@ -475,7 +476,7 @@
 def check_syslib_dependencies(bld, t):
     '''check for syslib depenencies'''
 
-    if bld.name_to_obj(t.sname + ".objlist", bld.env):
+    if bld.get_tgen_by_name(t.sname + ".objlist"):
         return
 
     sname = real_name(t.sname)
diff -Nru tevent-0.9.25/buildtools/wafsamba/wafsamba.py tevent-0.9.28/buildtools/wafsamba/wafsamba.py
--- tevent-0.9.25/buildtools/wafsamba/wafsamba.py	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/wafsamba.py	2016-02-26 03:24:44.000000000 +0000
@@ -20,6 +20,7 @@
 from samba_deps import *
 from samba_bundled import *
 from samba_third_party import *
+import samba_cross
 import samba_install
 import samba_conftests
 import samba_abi
@@ -95,9 +96,7 @@
 
 
 def generate_empty_file(task):
-    target_fname = installed_location=task.outputs[0].bldpath(task.env)
-    target_file = open(installed_location, 'w')
-    target_file.close()
+    task.outputs[0].write('')
     return 0
 
 #################################################################
@@ -107,6 +106,7 @@
                   includes='',
                   public_headers=None,
                   public_headers_install=True,
+                  private_headers=None,
                   header_path=None,
                   pc_files=None,
                   vnum=None,
@@ -146,8 +146,12 @@
     if pyembed and bld.env['IS_EXTRA_PYTHON']:
         public_headers = pc_files = None
 
+    if private_library and public_headers:
+        raise Utils.WafError("private library '%s' must not have public header files" %
+                             libname)
+
     if LIB_MUST_BE_PRIVATE(bld, libname):
-        private_library=True
+        private_library = True
 
     if not enabled:
         SET_TARGET_TYPE(bld, libname, 'DISABLED')
@@ -188,6 +192,7 @@
                         includes       = includes,
                         public_headers = public_headers,
                         public_headers_install = public_headers_install,
+                        private_headers= private_headers,
                         header_path    = header_path,
                         cflags         = cflags,
                         group          = subsystem_group,
@@ -242,8 +247,10 @@
                                     bundled_extension, private_library)
 
     ldflags = TO_LIST(ldflags)
+    if bld.env['ENABLE_RELRO'] is True:
+        ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
 
-    features = 'cc cshlib symlink_lib install_lib'
+    features = 'c cshlib symlink_lib install_lib'
     if pyext:
         features += ' pyext'
     if pyembed:
@@ -252,6 +259,15 @@
     if abi_directory:
         features += ' abi_check'
 
+    if pyembed and bld.env['PYTHON_SO_ABI_FLAG']:
+        # For ABI checking, we don't care about the exact Python version.
+        # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3"
+        abi_flag = bld.env['PYTHON_SO_ABI_FLAG']
+        replacement = '.py%s' % bld.env['PYTHON_VERSION'].split('.')[0]
+        version_libname = libname.replace(abi_flag, replacement)
+    else:
+        version_libname = libname
+
     vscript = None
     if bld.env.HAVE_LD_VERSION_SCRIPT:
         if private_library:
@@ -262,7 +278,7 @@
             version = None
         if version:
             vscript = "%s.vscript" % libname
-            bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
+            bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript,
                             abi_match)
             fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
             fullpath = bld.path.find_or_declare(fullname)
@@ -272,7 +288,7 @@
             if not vscriptpath:
                 raise Utils.WafError("unable to find vscript path for %s" % vscript)
             bld.add_manual_dependency(fullpath, vscriptpath)
-            if Options.is_install:
+            if bld.is_install:
                 # also make the .inst file depend on the vscript
                 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
                 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
@@ -288,6 +304,7 @@
         samba_deps      = deps,
         samba_includes  = includes,
         version_script  = vscript,
+        version_libname = version_libname,
         local_include   = local_include,
         global_include  = global_include,
         vnum            = vnum,
@@ -326,6 +343,7 @@
                  deps='',
                  includes='',
                  public_headers=None,
+                 private_headers=None,
                  header_path=None,
                  modules=None,
                  ldflags=None,
@@ -354,7 +372,7 @@
     if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
         return
 
-    features = 'cc cprogram symlink_bin install_bin'
+    features = 'c cprogram symlink_bin install_bin'
     if pyembed:
         features += ' pyembed'
 
@@ -528,6 +546,7 @@
                     includes='',
                     public_headers=None,
                     public_headers_install=True,
+                    private_headers=None,
                     header_path=None,
                     cflags='',
                     cflags_end=None,
@@ -578,7 +597,7 @@
 
     bld.SET_BUILD_GROUP(group)
 
-    features = 'cc'
+    features = 'c'
     if pyext:
         features += ' pyext'
     if pyembed:
@@ -620,6 +639,7 @@
                     group='generators', enabled=True,
                     public_headers=None,
                     public_headers_install=True,
+                    private_headers=None,
                     header_path=None,
                     vars=None,
                     dep_vars=[],
@@ -663,7 +683,7 @@
 
 
 
-@runonce
+@Utils.run_once
 def SETUP_BUILD_GROUPS(bld):
     '''setup build groups used to ensure that the different build
     phases happen consecutively'''
@@ -716,7 +736,7 @@
     '''used to copy scripts from the source tree into the build directory
        for use by selftest'''
 
-    source = bld.path.ant_glob(pattern)
+    source = bld.path.ant_glob(pattern, flat=True)
 
     bld.SET_BUILD_GROUP('build_source')
     for s in TO_LIST(source):
@@ -845,7 +865,7 @@
 def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
                      python_fixup=False, exclude=None, trim_path=None):
     '''install a set of files matching a wildcard pattern'''
-    files=TO_LIST(bld.path.ant_glob(pattern))
+    files=TO_LIST(bld.path.ant_glob(pattern, flat=True))
     if trim_path:
         files2 = []
         for f in files:
diff -Nru tevent-0.9.25/buildtools/wafsamba/wscript tevent-0.9.28/buildtools/wafsamba/wscript
--- tevent-0.9.25/buildtools/wafsamba/wscript	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/buildtools/wafsamba/wscript	2016-02-26 03:24:44.000000000 +0000
@@ -2,9 +2,9 @@
 
 # this is a base set of waf rules that everything else pulls in first
 
-import sys, wafsamba, Configure, Logs
-import Options, os, preproc
-from samba_utils import *
+import os, sys
+import wafsamba, Configure, Logs, Options, Utils
+from samba_utils import os_path_relpath
 from optparse import SUPPRESS_HELP
 
 # this forces configure to be re-run if any of the configure
@@ -78,9 +78,6 @@
                    help='additional directory to search for libiconv',
                    action='store', dest='iconv_open', default='/usr/local',
                    match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
-    opt.add_option('--with-gettext',
-                   help='additional directory to search for gettext',
-                   action='store', dest='gettext_location', default='None')
     opt.add_option('--without-gettext',
                    help=("Disable use of gettext"),
                    action="store_true", dest='disable_gettext', default=False)
@@ -99,9 +96,13 @@
     gr.add_option('--enable-developer',
                    help=("Turn on developer warnings and debugging"),
                    action="store_true", dest='developer', default=False)
+    def picky_developer_callback(option, opt_str, value, parser):
+        parser.values.developer = True
+        parser.values.picky_developer = True
     gr.add_option('--picky-developer',
                    help=("Treat all warnings as errors (enable -Werror)"),
-                   action="store_true", dest='picky_developer', default=False)
+                   action="callback", callback=picky_developer_callback,
+                   dest='picky_developer', default=False)
     gr.add_option('--fatal-errors',
                    help=("Stop compilation on first error (enable -Wfatal-errors)"),
                    action="store_true", dest='fatal_errors', default=False)
@@ -202,7 +203,7 @@
                     metavar="PYTHON", dest='EXTRA_PYTHON', default=None)
 
 
-@wafsamba.runonce
+@Utils.run_once
 def configure(conf):
     conf.env.hlist = []
     conf.env.srcdir = conf.srcdir
@@ -215,6 +216,7 @@
     # load our local waf extensions
     conf.check_tool('gnu_dirs')
     conf.check_tool('wafsamba')
+    conf.check_tool('print_commands')
 
     conf.CHECK_CC_ENV()
 
@@ -227,6 +229,11 @@
 
     # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
     if Options.options.enable_gccdeps:
+        # stale file removal - the configuration may pick up the old .pyc file
+        p = os.path.join(conf.srcdir, 'buildtools/wafsamba/gccdeps.pyc')
+        if os.path.exists(p):
+            os.remove(p)
+
         from TaskGen import feature, after
         @feature('testd')
         @after('apply_core')
@@ -241,7 +248,7 @@
         cc.run = Task.compile_fun_noshell('cc', '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath(env)}')[0]
         try:
             try:
-                conf.check(features='cc testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
+                conf.check(features='c testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
             except:
                 pass
             else:
@@ -361,6 +368,40 @@
                         cflags=conf.env.VISIBILITY_CFLAGS,
                         define='HAVE_VISIBILITY_ATTR', addmain=False)
 
+    # check HAVE_CONSTRUCTOR_ATTRIBUTE
+    conf.CHECK_CODE('''
+            void test_constructor_attribute(void) __attribute__ ((constructor));
+
+            void test_constructor_attribute(void)
+            {
+                return;
+            }
+
+            int main(void) {
+                return 0;
+            }
+            ''',
+            'HAVE_CONSTRUCTOR_ATTRIBUTE',
+            addmain=False,
+            msg='Checking for library constructor support')
+
+        # check HAVE_DESTRUCTOR_ATTRIBUTE
+    conf.CHECK_CODE('''
+            void test_destructor_attribute(void) __attribute__ ((destructor));
+
+            void test_destructor_attribute(void)
+            {
+                return;
+            }
+
+            int main(void) {
+                return 0;
+            }
+            ''',
+            'HAVE_DESTRUCTOR_ATTRIBUTE',
+            addmain=False,
+            msg='Checking for library destructor support')
+
     if sys.platform.startswith('aix'):
         conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
         # Might not be needed if ALL_SOURCE is defined
diff -Nru tevent-0.9.25/debian/autodeps.py tevent-0.9.28/debian/autodeps.py
--- tevent-0.9.25/debian/autodeps.py	2016-04-11 20:42:16.000000000 +0000
+++ tevent-0.9.28/debian/autodeps.py	2016-10-08 22:31:26.000000000 +0000
@@ -118,10 +118,9 @@
 
 def forced_minimum_library_versions():
     libraries = [
-        ("tdb", "lib/tdb/wscript"),
         ("talloc", "lib/talloc/wscript"),
-        ("ldb", "source4/lib/ldb/wscript"),
-        ("tevent", "lib/tevent/wscript")]
+        ("pytalloc-util", "lib/talloc/wscript"),
+        ]
     eq_config = LibraryEquivalents('debian/library-equivalents')
     for (name, path) in libraries:
         version = find_version(os.path.join(tree, path))
diff -Nru tevent-0.9.25/debian/changelog tevent-0.9.28/debian/changelog
--- tevent-0.9.25/debian/changelog	2016-04-12 05:41:59.000000000 +0000
+++ tevent-0.9.28/debian/changelog	2016-10-08 22:31:26.000000000 +0000
@@ -1,3 +1,11 @@
+tevent (0.9.28-0+deb8u1) UNRELEASED; urgency=high
+
+  * Upload to stable for Samba security release.
+  * Drop 01_fix_ld_library patch; applied upstream.
+  * Allow build against older talloc.
+
+ -- Jelmer Vernooij <jelmer@debian.org>  Sat, 08 Oct 2016 22:31:26 +0000
+
 tevent (0.9.25-0+deb8u1) jessie-security; urgency=high
 
   [ Andrew Bartlett ]
diff -Nru tevent-0.9.25/debian/library-equivalents tevent-0.9.28/debian/library-equivalents
--- tevent-0.9.25/debian/library-equivalents	2016-04-11 20:42:16.000000000 +0000
+++ tevent-0.9.28/debian/library-equivalents	2016-10-08 22:31:26.000000000 +0000
@@ -8,3 +8,14 @@
 2.0.2 = 2.0.1
 2.0.3 = 2.0.1
 2.0.4 = 2.0.1
+2.1.3 = 2.1.2
+2.1.4 = 2.1.2
+2.1.5 = 2.1.2
+
+[pytalloc-util]
+2.0.2 = 2.0.1
+2.0.3 = 2.0.1
+2.0.4 = 2.0.1
+2.1.3 = 2.1.2
+2.1.4 = 2.1.2
+2.1.5 = 2.1.2
diff -Nru tevent-0.9.25/debian/libtevent0.symbols tevent-0.9.28/debian/libtevent0.symbols
--- tevent-0.9.25/debian/libtevent0.symbols	2016-04-12 05:38:24.000000000 +0000
+++ tevent-0.9.28/debian/libtevent0.symbols	2016-10-08 22:31:26.000000000 +0000
@@ -16,6 +16,9 @@
  TEVENT_0.9.23@TEVENT_0.9.23 0.9.23
  TEVENT_0.9.24@TEVENT_0.9.24 0.9.24
  TEVENT_0.9.25@TEVENT_0.9.25 0.9.25
+ TEVENT_0.9.26@TEVENT_0.9.26 0.9.26
+ TEVENT_0.9.27@TEVENT_0.9.27 0.9.27
+ TEVENT_0.9.28@TEVENT_0.9.28 0.9.28
  _tevent_add_fd@TEVENT_0.9.9 0.9.9
  _tevent_add_signal@TEVENT_0.9.9 0.9.9
  _tevent_add_timer@TEVENT_0.9.9 0.9.9
@@ -93,6 +96,8 @@
  tevent_set_default_backend@TEVENT_0.9.9 0.9.9
  tevent_set_trace_callback@TEVENT_0.9.16 0.9.16
  tevent_signal_support@TEVENT_0.9.9 0.9.9
+ tevent_thread_proxy_create@TEVENT_0.9.26 0.9.26
+ tevent_thread_proxy_schedule@TEVENT_0.9.26 0.9.26
  tevent_timeval_add@TEVENT_0.9.9 0.9.9
  tevent_timeval_compare@TEVENT_0.9.9 0.9.9
  tevent_timeval_current@TEVENT_0.9.9 0.9.9
diff -Nru tevent-0.9.25/debian/patches/01_fix_ld_library_path tevent-0.9.28/debian/patches/01_fix_ld_library_path
--- tevent-0.9.25/debian/patches/01_fix_ld_library_path	2016-04-12 05:38:24.000000000 +0000
+++ tevent-0.9.28/debian/patches/01_fix_ld_library_path	1970-01-01 00:00:00.000000000 +0000
@@ -1,14 +0,0 @@
-diff --git a/wscript b/wscript
-index 4c5fe0c..73871d8 100755
---- a/wscript
-+++ b/wscript
-@@ -133,6 +133,9 @@ def test(ctx):
-     '''test tevent'''
-     print("The tevent testsuite is part of smbtorture in samba4")
- 
-+    samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
-+    samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
-+
-     pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
-     sys.exit(pyret)
- 
diff -Nru tevent-0.9.25/debian/patches/series tevent-0.9.28/debian/patches/series
--- tevent-0.9.25/debian/patches/series	2016-04-12 05:38:24.000000000 +0000
+++ tevent-0.9.28/debian/patches/series	2016-10-08 22:31:26.000000000 +0000
@@ -1 +0,0 @@
-01_fix_ld_library_path
diff -Nru tevent-0.9.25/debian/rules tevent-0.9.28/debian/rules
--- tevent-0.9.25/debian/rules	2016-04-12 05:38:24.000000000 +0000
+++ tevent-0.9.28/debian/rules	2016-10-08 22:31:26.000000000 +0000
@@ -19,7 +19,7 @@
 override_dh_auto_configure:
 	CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" ./configure --prefix=/usr --bundled-libraries=NONE \
 		   --disable-rpath --disable-rpath-install \
-		   --minimum-library-version="$(shell ./debian/autodeps.py --minimum-library-version)" \
+		   --minimum-library-version="$(shell ./debian/autodeps.py --minimum-library-version .)" \
 		   --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
 
 override_dh_auto_build:
diff -Nru tevent-0.9.25/doc/tevent_thread.dox tevent-0.9.28/doc/tevent_thread.dox
--- tevent-0.9.25/doc/tevent_thread.dox	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/doc/tevent_thread.dox	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,322 @@
+/**
+@page tevent_context Chapter 6: Tevent with threads
+
+@section context Tevent with threads
+
+In order to use tevent with threads, you must first understand
+how to use the talloc library in threaded programs. For more
+information about working with talloc, please visit <a
+href="https://talloc.samba.org/";>talloc website</a> where tutorial and
+documentation are located.
+
+If a tevent context structure is talloced from a NULL, thread-safe talloc
+context, then it can be safe to use in a threaded program. The function
+<code>talloc_disable_null_tracking()</code> <b>must</b> be called from the initial
+program thread before any talloc calls are made to ensure talloc is thread-safe.
+
+Each thread must create it's own tevent context structure as follows
+<code>tevent_context_init(NULL)</code> and no talloc memory contexts
+can be shared between threads.
+
+Separate threads using tevent in this way can communicate
+by writing data into file descriptors that are being monitored
+by a tevent context on another thread. For example (simplified
+with no error handling):
+
+@code
+Main thread:
+
+main()
+{
+	talloc_disable_null_tracking();
+
+	struct tevent_context *master_ev = tevent_context_init(NULL);
+	void *mem_ctx = talloc_new(master_ev);
+
+	// Create file descriptor to monitor.
+	int pipefds[2];
+
+	pipe(pipefds);
+
+	struct tevent_fd *fde = tevent_add_fd(master_ev,
+				mem_ctx,
+				pipefds[0], // read side of pipe
+				TEVENT_FD_READ,
+				pipe_read_handler, // callback function
+				private_data_pointer);
+
+	// Create sub thread, pass pipefds[1] write side of pipe to it.
+	// The above code not shown here..
+
+	// Process events.
+	tevent_loop_wait(master_ev);
+
+	// Cleanup if loop exits.
+	talloc_free(master_ev);
+}
+
+@endcode
+
+When the subthread writes to pipefds[1], the function
+<code>pipe_read_handler()</code> will be called in the main thread.
+
+@subsection More sophisticated use
+
+A popular way to use an event library within threaded programs
+is to allow a sub-thread to asynchronously schedule a tevent_immediate
+function call from the event loop of another thread. This can be built
+out of the basic functions and isolation mechanisms of tevent,
+but tevent also comes with some utility functions that make
+this easier, so long as you understand the limitations that
+using threads with talloc and tevent impose.
+
+To allow a tevent context to receive an asynchronous tevent_immediate
+function callback from another thread, create a struct tevent_thread_proxy *
+by calling @code
+
+struct tevent_thread_proxy *tevent_thread_proxy_create(
+                struct tevent_context *dest_ev_ctx);
+
+@endcode
+
+This function allocates the internal data structures to
+allow asynchronous callbacks as a talloc child of the
+struct tevent_context *, and returns a struct tevent_thread_proxy *
+that can be passed to another thread.
+
+When you have finished receiving asynchronous callbacks, simply
+talloc_free the struct tevent_thread_proxy *, or talloc_free
+the struct tevent_context *, which will deallocate the resources
+used.
+
+To schedule an asynchronous tevent_immediate function call from one
+thread on the tevent loop of another thread, use
+@code
+
+void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
+                                struct tevent_immediate **pp_im,
+                                tevent_immediate_handler_t handler,
+                                void **pp_private_data);
+
+@endcode
+
+This function causes the function <code>handler()</code>
+to be invoked as a tevent_immediate callback from the event loop
+of the thread that created the struct tevent_thread_proxy *
+(so the owning <code>struct tevent_context *</code> should be
+long-lived and not in the process of being torn down).
+
+The <code>struct tevent_thread_proxy</code> object being
+used here is a child of the event context of the target
+thread. So external synchronization mechanisms must be
+used to ensure that the target object is still in use
+at the time of the <code>tevent_thread_proxy_schedule()</code>
+call. In the example below, the request/response nature
+of the communication ensures this.
+
+The <code>struct tevent_immediate **pp_im</code> passed into this function
+should be a struct tevent_immediate * allocated on a talloc context
+local to this thread, and will be reparented via talloc_move
+to be owned by <code>struct tevent_thread_proxy *tp</code>.
+<code>*pp_im</code> will be set to NULL on successful scheduling
+of the tevent_immediate call.
+
+<code>handler()</code> will be called as a normal tevent_immediate
+callback from the <code>struct tevent_context *</code> of the destination
+event loop that created the <code>struct tevent_thread_proxy *</code>
+
+Returning from this functions does not mean that the <code>handler</code>
+has been invoked, merely that it has been scheduled to be called in the
+destination event loop.
+
+Because the calling thread does not wait for the
+callback to be scheduled and run on the destination
+thread, this is a fire-and-forget call. If you wish
+confirmation of the <code>handler()</code> being
+successfully invoked, you must ensure it replies to the
+caller in some way.
+
+Because of asynchronous nature of this call, the nature
+of the parameter passed to the destination thread has some
+restructions. If you don't need parameters, merely pass
+<code>NULL</code> as the value of
+<code>void **pp_private_data</code>.
+
+If you wish to pass a pointer to data between the threads,
+it <b>MUST</b> be a pointer to a talloced pointer, which is
+not part of a talloc-pool, and it must not have a destructor
+attached. The ownership of the memory pointed to will
+be passed from the calling thread to the tevent library,
+and if the receiving thread does not talloc-reparent
+it to its own contexts, it will be freed once the
+<code>handler</code> is called.
+
+On success, <code>*pp_private</code> will be <code>NULL</code>
+to signify the talloc memory ownership has been moved.
+
+In practice for message passing between threads in
+event loops these restrictions are not very onerous.
+
+The easiest way to to a request-reply pair between
+tevent loops on different threads is to pass the
+parameter block of memory back and forth using
+a reply <code>tevent_thread_proxy_schedule()</code>
+call.
+
+Here is an example (without error checking for
+simplicity):
+
+@code
+------------------------------------------------
+// Master thread.
+
+main()
+{
+	// Make talloc thread-safe.
+
+	talloc_disable_null_tracking();
+
+	// Create the master event context.
+
+	struct tevent_context *master_ev = tevent_context_init(NULL);
+
+	// Create the master thread proxy to allow it to receive
+	// async callbacks from other threads.
+
+	struct tevent_thread_proxy *master_tp =
+			tevent_thread_proxy_create(master_ev);
+
+	// Create sub-threads, passing master_tp in
+	// some way to them.
+	// This code not shown..
+
+	// Process events.
+	// Function master_callback() below
+	// will be invoked on this thread on
+	// master_ev event context.
+
+	tevent_loop_wait(master_ev);
+
+	// Cleanup if loop exits.
+
+	talloc_free(master_ev);
+}
+
+// Data passed between threads.
+struct reply_state {
+	struct tevent_thread_proxy *reply_tp;
+	pthread_t thread_id;
+	bool *p_finished;
+};
+
+// Callback Called in child thread context.
+
+static void thread_callback(struct tevent_context *ev,
+                                struct tevent_immediate *im,
+                                void *private_ptr)
+{
+	// Move the ownership of what private_ptr
+	// points to from the tevent library back to this thread.
+
+	struct reply_state *rsp =
+		talloc_get_type_abort(private_ptr, struct reply_state);
+
+	talloc_steal(ev, rsp);
+
+	*rsp->p_finished = true;
+
+	// im will be talloc_freed on return from this call.
+	// but rsp will not.
+}
+
+// Callback Called in master thread context.
+
+static void master_callback(struct tevent_context *ev,
+                                struct tevent_immediate *im,
+                                void *private_ptr)
+{
+	// Move the ownership of what private_ptr
+	// points to from the tevent library to this thread.
+
+	struct reply_state *rsp =
+		talloc_get_type_abort(private_ptr, struct reply_state);
+
+	talloc_steal(ev, rsp);
+
+	printf("Callback from thread %s\n", thread_id_to_string(rsp->thread_id));
+
+	/* Now reply to the thread ! */
+	tevent_thread_proxy_schedule(rsp->reply_tp,
+				&im,
+				thread_callback,
+				&rsp);
+
+	// Note - rsp and im are now NULL as the tevent library
+	// owns the memory.
+}
+
+// Child thread.
+
+static void *thread_fn(void *private_ptr)
+{
+	struct tevent_thread_proxy *master_tp =
+		talloc_get_type_abort(private_ptr, struct tevent_thread_proxy);
+	bool finished = false;
+	int ret;
+
+	// Create our own event context.
+
+	struct tevent_context *ev = tevent_context_init(NULL);
+
+	// Create the local thread proxy to allow us to receive
+	// async callbacks from other threads.
+
+	struct tevent_thread_proxy *local_tp =
+			tevent_thread_proxy_create(master_ev);
+
+	// Setup the data to send.
+
+	struct reply_state *rsp = talloc(ev, struct reply_state);
+
+	rsp->reply_tp = local_tp;
+	rsp->thread_id = pthread_self();
+	rsp->p_finished = &finished;
+
+	// Create the immediate event to use.
+
+	struct tevent_immediate *im = tevent_create_immediate(ev);
+
+	// Call the master thread.
+
+	tevent_thread_proxy_schedule(master_tp,
+				&im,
+				master_callback,
+				&rsp);
+
+	// Note - rsp and im are now NULL as the tevent library
+	// owns the memory.
+
+	// Wait for the reply.
+
+	while (!finished) {
+		tevent_loop_once(ev);
+	}
+
+	// Cleanup.
+
+	talloc_free(ev);
+	return NULL;
+}
+
+@endcode
+
+Note this doesn't have to be a master-subthread communication.
+Any thread that has access to the <code>struct tevent_thread_proxy *</code>
+pointer of another thread that has called <code>tevent_thread_proxy_create()
+</code> can send an async tevent_immediate request.
+
+But remember the caveat that external synchronization must be used
+to ensure the target <code>struct tevent_thread_proxy *</code> object
+exists at the time of the <code>tevent_thread_proxy_schedule()</code>
+call or unreproducible crashes will result.
+*/
diff -Nru tevent-0.9.25/doc/tevent_tutorial.dox tevent-0.9.28/doc/tevent_tutorial.dox
--- tevent-0.9.25/doc/tevent_tutorial.dox	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/doc/tevent_tutorial.dox	2016-02-26 03:24:44.000000000 +0000
@@ -17,4 +17,6 @@
 
 @subpage tevent_queue
 
+@subpage tevent_thread
+
 */
diff -Nru tevent-0.9.25/lib/replace/replace.c tevent-0.9.28/lib/replace/replace.c
--- tevent-0.9.25/lib/replace/replace.c	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/lib/replace/replace.c	2016-02-26 03:24:44.000000000 +0000
@@ -475,6 +475,26 @@
 }
 #endif
 
+#ifndef HAVE_STRSEP
+char *rep_strsep(char **pps, const char *delim)
+{
+	char *ret = *pps;
+	char *p = *pps;
+
+	if (p == NULL) {
+		return NULL;
+	}
+	p += strcspn(p, delim);
+	if (*p == '\0') {
+		*pps = NULL;
+	} else {
+		*p = '\0';
+		*pps = p + 1;
+	}
+	return ret;
+}
+#endif
+
 #ifndef HAVE_STRTOK_R
 /* based on GLIBC version, copyright Free Software Foundation */
 char *rep_strtok_r(char *s, const char *delim, char **save_ptr)
@@ -518,25 +538,23 @@
 }
 #else
 #ifdef HAVE_BSD_STRTOLL
-#ifdef HAVE_STRTOQ
+#undef strtoll
 long long int rep_strtoll(const char *str, char **endptr, int base)
 {
-	long long int nb = strtoq(str, endptr, base);
-	/* In linux EINVAL is only returned if base is not ok */
+	int saved_errno = errno;
+	long long int nb = strtoll(str, endptr, base);
+	/* With glibc EINVAL is only returned if base is not ok */
 	if (errno == EINVAL) {
 		if (base == 0 || (base >1 && base <37)) {
 			/* Base was ok so it's because we were not
 			 * able to make the convertion.
 			 * Let's reset errno.
 			 */
-			errno = 0;
+			errno = saved_errno;
 		}
 	}
 	return nb;
 }
-#else
-#error "You need the strtoq function"
-#endif /* HAVE_STRTOQ */
 #endif /* HAVE_BSD_STRTOLL */
 #endif /* HAVE_STRTOLL */
 
@@ -556,25 +574,23 @@
 }
 #else
 #ifdef HAVE_BSD_STRTOLL
-#ifdef HAVE_STRTOUQ
+#undef strtoull
 unsigned long long int rep_strtoull(const char *str, char **endptr, int base)
 {
-	unsigned long long int nb = strtouq(str, endptr, base);
-	/* In linux EINVAL is only returned if base is not ok */
+	int saved_errno = errno;
+	unsigned long long int nb = strtoull(str, endptr, base);
+	/* With glibc EINVAL is only returned if base is not ok */
 	if (errno == EINVAL) {
 		if (base == 0 || (base >1 && base <37)) {
 			/* Base was ok so it's because we were not
 			 * able to make the convertion.
 			 * Let's reset errno.
 			 */
-			errno = 0;
+			errno = saved_errno;
 		}
 	}
 	return nb;
 }
-#else
-#error "You need the strtouq function"
-#endif /* HAVE_STRTOUQ */
 #endif /* HAVE_BSD_STRTOLL */
 #endif /* HAVE_STRTOULL */
 
@@ -812,7 +828,7 @@
 	struct timeval tval;
 	switch (clk_id) {
 		case 0: /* CLOCK_REALTIME :*/
-#ifdef HAVE_GETTIMEOFDAY_TZ
+#if defined(HAVE_GETTIMEOFDAY_TZ) || defined(HAVE_GETTIMEOFDAY_TZ_VOID)
 			gettimeofday(&tval,NULL);
 #else
 			gettimeofday(&tval);
diff -Nru tevent-0.9.25/lib/replace/replace.h tevent-0.9.28/lib/replace/replace.h
--- tevent-0.9.25/lib/replace/replace.h	2014-10-01 09:22:21.000000000 +0000
+++ tevent-0.9.28/lib/replace/replace.h	2016-02-26 03:24:44.000000000 +0000
@@ -349,6 +349,11 @@
 char *rep_strcasestr(const char *haystack, const char *needle);
 #endif
 
+#ifndef HAVE_STRSEP
+#define strsep rep_strsep
+char *rep_strsep(char **pps, const char *delim);
+#endif
+
 #ifndef HAVE_STRTOK_R
 #define strtok_r rep_strtok_r
 char *rep_strtok_r(char *s, const char *delim, char **save_ptr);
diff -Nru tevent-0.9.25/lib/replace/system/threads.h tevent-0.9.28/lib/replace/system/threads.h
--- tevent-0.9.25/lib/replace/system/threads.h	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/lib/replace/system/threads.h	2016-02-26 03:24:44.000000000 +0000
@@ -29,15 +29,12 @@
 
 #if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && \
 	!defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST)
-
 #define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
+#endif
 
-/*
- * We assume that PTHREAD_MUTEX_ROBUST_NP goes along with
- * pthread_mutexattr_setrobust_np()
- */
+#if defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP) && \
+	!defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST)
 #define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
-
 #endif
 
 #if defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) && \
diff -Nru tevent-0.9.25/lib/replace/wscript tevent-0.9.28/lib/replace/wscript
--- tevent-0.9.25/lib/replace/wscript	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/lib/replace/wscript	2016-02-26 03:24:44.000000000 +0000
@@ -14,7 +14,7 @@
 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 
 import wafsamba, samba_dist
-import Options
+import Options, Utils
 
 samba_dist.DIST_DIRS('lib/replace buildtools:buildtools third_party/waf:third_party/waf')
 
@@ -23,7 +23,7 @@
     opt.PRIVATE_EXTENSION_DEFAULT('')
     opt.RECURSE('buildtools/wafsamba')
 
-@wafsamba.runonce
+@Utils.run_once
 def configure(conf):
     conf.RECURSE('buildtools/wafsamba')
 
@@ -43,7 +43,12 @@
     conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
     conf.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h sys/file.h')
-    conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h malloc.h grp.h')
+    conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h')
+
+    if not conf.CHECK_DECLS('malloc', headers='stdlib.h'):
+        conf.CHECK_HEADERS('malloc.h')
+
+    conf.CHECK_HEADERS('grp.h')
     conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
     conf.CHECK_HEADERS('stdarg.h vararg.h sys/mount.h mntent.h')
     conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
@@ -71,7 +76,7 @@
     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
-    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
+    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
     conf.CHECK_HEADERS('sys/atomic.h')
     conf.CHECK_HEADERS('libgen.h')
@@ -240,11 +245,15 @@
     conf.CHECK_FUNCS('lstat getpgrp utime utimes setuid seteuid setreuid setresuid setgid setegid')
     conf.CHECK_FUNCS('setregid setresgid chroot strerror vsyslog setlinebuf mktime')
     conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4')
-    conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr')
+    conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr strsep')
     conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
     conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
     conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
+
+    if conf.CONFIG_SET('HAVE_MEMALIGN'):
+        conf.CHECK_DECLS('memalign', headers='malloc.h')
+
     conf.CHECK_FUNCS('prctl dirname basename')
 
     # libbsd on some platforms provides strlcpy and strlcat
@@ -361,13 +370,6 @@
     # try to find libintl (if --without-gettext is not given)
     conf.env.intl_libs=''
     if not Options.options.disable_gettext:
-        # any extra path given to look at?
-        if not Options.options.gettext_location == 'None':
-           conf.env['CFLAGS'].extend(["-I%s" % Options.options.gettext_location]);
-           conf.env['LDFLAGS'].extend(["-L%s" % Options.options.gettext_location]);
-        else:
-           conf.env['CFLAGS'].extend(["-I/usr/local"]);
-           conf.env['LDFLAGS'].extend(["-L/usr/local"]);
         conf.CHECK_HEADERS('libintl.h')
         conf.CHECK_LIB('intl')
         conf.CHECK_DECLS('dgettext gettext bindtextdomain textdomain bind_textdomain_codeset', headers="libintl.h")
@@ -407,10 +409,6 @@
        conf.undefine('HAVE_DGETTEXT')
        conf.undefine('HAVE_DECL_DGETTEXT')
 
-    # did the user insist on gettext (--with-gettext)?
-    if Options.options.gettext_location != 'None' and (not conf.env['HAVE_GETTEXT'] or not conf.env['HAVE_DGETTEXT']):
-        conf.fatal('library gettext not found at specified location')
-
     conf.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc=True, headers='pthread.h')
 
     PTHREAD_CFLAGS='error'
@@ -448,21 +446,15 @@
 
     if conf.CONFIG_SET('HAVE_PTHREAD'):
 
-        conf.CHECK_DECLS('pthread_mutexattr_setrobust', headers='pthread.h')
-        if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEXATTR_SETROBUST'):
-            conf.CHECK_DECLS('pthread_mutexattr_setrobust_np',
-                             headers='pthread.h')
-
         conf.CHECK_FUNCS_IN('pthread_mutexattr_setrobust', 'pthread',
                             checklibc=True, headers='pthread.h')
         if not conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST'):
             conf.CHECK_FUNCS_IN('pthread_mutexattr_setrobust_np', 'pthread',
                                 checklibc=True, headers='pthread.h')
 
-        conf.CHECK_DECLS('pthread_mutex_consistent', headers='pthread.h')
-        if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_CONSISTENT'):
-            conf.CHECK_DECLS('pthread_mutex_consistent_np',
-                             headers='pthread.h')
+        conf.CHECK_DECLS('PTHREAD_MUTEX_ROBUST', headers='pthread.h')
+        if not conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST'):
+            conf.CHECK_DECLS('PTHREAD_MUTEX_ROBUST_NP', headers='pthread.h')
 
         conf.CHECK_FUNCS_IN('pthread_mutex_consistent', 'pthread',
                             checklibc=True, headers='pthread.h')
@@ -472,6 +464,8 @@
 
         if ((conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST') or
              conf.CONFIG_SET('HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP')) and
+            (conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST') or
+             conf.CONFIG_SET('HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP')) and
             (conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT') or
              conf.CONFIG_SET('HAVE_PTHREAD_MUTEX_CONSISTENT_NP'))):
             conf.DEFINE('HAVE_ROBUST_MUTEXES', 1)
@@ -506,7 +500,14 @@
                        addmain=False,
                        msg='Checking for working strptime')
 
-    conf.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute=False)
+    conf.CHECK_C_PROTOTYPE('gettimeofday',
+                           'int gettimeofday(struct timeval *tv, struct timezone *tz)',
+                           define='HAVE_GETTIMEOFDAY_TZ', headers='sys/time.h')
+
+    conf.CHECK_C_PROTOTYPE('gettimeofday',
+                           'int gettimeofday(struct timeval *tv, void *tz)',
+                           define='HAVE_GETTIMEOFDAY_TZ_VOID',
+                           headers='sys/time.h')
 
     conf.CHECK_CODE('#include "test/snprintf.c"',
                     define="HAVE_C99_VSNPRINTF",
@@ -634,7 +635,7 @@
                   'memmove', 'strdup', 'setlinebuf', 'vsyslog', 'strnlen',
                   'strndup', 'waitpid', 'seteuid', 'setegid', 'chroot',
                   'mkstemp', 'mkdtemp', 'pread', 'pwrite', 'strcasestr',
-                  'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv',
+                  'strsep', 'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv',
                   'utime', 'utimes', 'dup2', 'chown', 'link', 'readlink',
                   'symlink', 'lchown', 'realpath', 'memmem', 'vdprintf',
                   'dprintf', 'get_current_dir_name',
diff -Nru tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.3.sigs tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.3.sigs
--- tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.3.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.3.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,6 @@
+pytalloc_CObject_FromTallocPtr: PyObject *(void *)
+pytalloc_Check: int (PyObject *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff -Nru tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.4.sigs tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.4.sigs
--- tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.4.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.4.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,6 @@
+pytalloc_CObject_FromTallocPtr: PyObject *(void *)
+pytalloc_Check: int (PyObject *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff -Nru tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.5.sigs tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.5.sigs
--- tevent-0.9.25/lib/talloc/ABI/pytalloc-util-2.1.5.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/pytalloc-util-2.1.5.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,6 @@
+pytalloc_CObject_FromTallocPtr: PyObject *(void *)
+pytalloc_Check: int (PyObject *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff -Nru tevent-0.9.25/lib/talloc/ABI/pytalloc-util.py3-2.1.5.sigs tevent-0.9.28/lib/talloc/ABI/pytalloc-util.py3-2.1.5.sigs
--- tevent-0.9.25/lib/talloc/ABI/pytalloc-util.py3-2.1.5.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/pytalloc-util.py3-2.1.5.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,5 @@
+pytalloc_Check: int (PyObject *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff -Nru tevent-0.9.25/lib/talloc/ABI/talloc-2.1.3.sigs tevent-0.9.28/lib/talloc/ABI/talloc-2.1.3.sigs
--- tevent-0.9.25/lib/talloc/ABI/talloc-2.1.3.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/talloc-2.1.3.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,64 @@
+_talloc: void *(const void *, size_t)
+_talloc_array: void *(const void *, size_t, unsigned int, const char *)
+_talloc_free: int (void *, const char *)
+_talloc_get_type_abort: void *(const void *, const char *, const char *)
+_talloc_memdup: void *(const void *, const void *, size_t, const char *)
+_talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
+_talloc_realloc: void *(const void *, void *, size_t, const char *)
+_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
+_talloc_reference_loc: void *(const void *, const void *, const char *)
+_talloc_set_destructor: void (const void *, int (*)(void *))
+_talloc_steal_loc: void *(const void *, const void *, const char *)
+_talloc_zero: void *(const void *, size_t, const char *)
+_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
+talloc_asprintf: char *(const void *, const char *, ...)
+talloc_asprintf_append: char *(char *, const char *, ...)
+talloc_asprintf_append_buffer: char *(char *, const char *, ...)
+talloc_autofree_context: void *(void)
+talloc_check_name: void *(const void *, const char *)
+talloc_disable_null_tracking: void (void)
+talloc_enable_leak_report: void (void)
+talloc_enable_leak_report_full: void (void)
+talloc_enable_null_tracking: void (void)
+talloc_enable_null_tracking_no_autofree: void (void)
+talloc_find_parent_byname: void *(const void *, const char *)
+talloc_free_children: void (void *)
+talloc_get_name: const char *(const void *)
+talloc_get_size: size_t (const void *)
+talloc_increase_ref_count: int (const void *)
+talloc_init: void *(const char *, ...)
+talloc_is_parent: int (const void *, const void *)
+talloc_named: void *(const void *, size_t, const char *, ...)
+talloc_named_const: void *(const void *, size_t, const char *)
+talloc_parent: void *(const void *)
+talloc_parent_name: const char *(const void *)
+talloc_pool: void *(const void *, size_t)
+talloc_realloc_fn: void *(const void *, void *, size_t)
+talloc_reference_count: size_t (const void *)
+talloc_reparent: void *(const void *, const void *, const void *)
+talloc_report: void (const void *, FILE *)
+talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
+talloc_report_depth_file: void (const void *, int, int, FILE *)
+talloc_report_full: void (const void *, FILE *)
+talloc_set_abort_fn: void (void (*)(const char *))
+talloc_set_log_fn: void (void (*)(const char *))
+talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
+talloc_set_name: const char *(const void *, const char *, ...)
+talloc_set_name_const: void (const void *, const char *)
+talloc_show_parents: void (const void *, FILE *)
+talloc_strdup: char *(const void *, const char *)
+talloc_strdup_append: char *(char *, const char *)
+talloc_strdup_append_buffer: char *(char *, const char *)
+talloc_strndup: char *(const void *, const char *, size_t)
+talloc_strndup_append: char *(char *, const char *, size_t)
+talloc_strndup_append_buffer: char *(char *, const char *, size_t)
+talloc_total_blocks: size_t (const void *)
+talloc_total_size: size_t (const void *)
+talloc_unlink: int (const void *, void *)
+talloc_vasprintf: char *(const void *, const char *, va_list)
+talloc_vasprintf_append: char *(char *, const char *, va_list)
+talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
+talloc_version_major: int (void)
+talloc_version_minor: int (void)
diff -Nru tevent-0.9.25/lib/talloc/ABI/talloc-2.1.4.sigs tevent-0.9.28/lib/talloc/ABI/talloc-2.1.4.sigs
--- tevent-0.9.25/lib/talloc/ABI/talloc-2.1.4.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/talloc-2.1.4.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,65 @@
+_talloc: void *(const void *, size_t)
+_talloc_array: void *(const void *, size_t, unsigned int, const char *)
+_talloc_free: int (void *, const char *)
+_talloc_get_type_abort: void *(const void *, const char *, const char *)
+_talloc_memdup: void *(const void *, const void *, size_t, const char *)
+_talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
+_talloc_realloc: void *(const void *, void *, size_t, const char *)
+_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
+_talloc_reference_loc: void *(const void *, const void *, const char *)
+_talloc_set_destructor: void (const void *, int (*)(void *))
+_talloc_steal_loc: void *(const void *, const void *, const char *)
+_talloc_zero: void *(const void *, size_t, const char *)
+_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
+talloc_asprintf: char *(const void *, const char *, ...)
+talloc_asprintf_append: char *(char *, const char *, ...)
+talloc_asprintf_append_buffer: char *(char *, const char *, ...)
+talloc_autofree_context: void *(void)
+talloc_check_name: void *(const void *, const char *)
+talloc_disable_null_tracking: void (void)
+talloc_enable_leak_report: void (void)
+talloc_enable_leak_report_full: void (void)
+talloc_enable_null_tracking: void (void)
+talloc_enable_null_tracking_no_autofree: void (void)
+talloc_find_parent_byname: void *(const void *, const char *)
+talloc_free_children: void (void *)
+talloc_get_name: const char *(const void *)
+talloc_get_size: size_t (const void *)
+talloc_increase_ref_count: int (const void *)
+talloc_init: void *(const char *, ...)
+talloc_is_parent: int (const void *, const void *)
+talloc_named: void *(const void *, size_t, const char *, ...)
+talloc_named_const: void *(const void *, size_t, const char *)
+talloc_parent: void *(const void *)
+talloc_parent_name: const char *(const void *)
+talloc_pool: void *(const void *, size_t)
+talloc_realloc_fn: void *(const void *, void *, size_t)
+talloc_reference_count: size_t (const void *)
+talloc_reparent: void *(const void *, const void *, const void *)
+talloc_report: void (const void *, FILE *)
+talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
+talloc_report_depth_file: void (const void *, int, int, FILE *)
+talloc_report_full: void (const void *, FILE *)
+talloc_set_abort_fn: void (void (*)(const char *))
+talloc_set_log_fn: void (void (*)(const char *))
+talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
+talloc_set_name: const char *(const void *, const char *, ...)
+talloc_set_name_const: void (const void *, const char *)
+talloc_show_parents: void (const void *, FILE *)
+talloc_strdup: char *(const void *, const char *)
+talloc_strdup_append: char *(char *, const char *)
+talloc_strdup_append_buffer: char *(char *, const char *)
+talloc_strndup: char *(const void *, const char *, size_t)
+talloc_strndup_append: char *(char *, const char *, size_t)
+talloc_strndup_append_buffer: char *(char *, const char *, size_t)
+talloc_test_get_magic: int (void)
+talloc_total_blocks: size_t (const void *)
+talloc_total_size: size_t (const void *)
+talloc_unlink: int (const void *, void *)
+talloc_vasprintf: char *(const void *, const char *, va_list)
+talloc_vasprintf_append: char *(char *, const char *, va_list)
+talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
+talloc_version_major: int (void)
+talloc_version_minor: int (void)
diff -Nru tevent-0.9.25/lib/talloc/ABI/talloc-2.1.5.sigs tevent-0.9.28/lib/talloc/ABI/talloc-2.1.5.sigs
--- tevent-0.9.25/lib/talloc/ABI/talloc-2.1.5.sigs	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/ABI/talloc-2.1.5.sigs	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,65 @@
+_talloc: void *(const void *, size_t)
+_talloc_array: void *(const void *, size_t, unsigned int, const char *)
+_talloc_free: int (void *, const char *)
+_talloc_get_type_abort: void *(const void *, const char *, const char *)
+_talloc_memdup: void *(const void *, const void *, size_t, const char *)
+_talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
+_talloc_realloc: void *(const void *, void *, size_t, const char *)
+_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
+_talloc_reference_loc: void *(const void *, const void *, const char *)
+_talloc_set_destructor: void (const void *, int (*)(void *))
+_talloc_steal_loc: void *(const void *, const void *, const char *)
+_talloc_zero: void *(const void *, size_t, const char *)
+_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
+talloc_asprintf: char *(const void *, const char *, ...)
+talloc_asprintf_append: char *(char *, const char *, ...)
+talloc_asprintf_append_buffer: char *(char *, const char *, ...)
+talloc_autofree_context: void *(void)
+talloc_check_name: void *(const void *, const char *)
+talloc_disable_null_tracking: void (void)
+talloc_enable_leak_report: void (void)
+talloc_enable_leak_report_full: void (void)
+talloc_enable_null_tracking: void (void)
+talloc_enable_null_tracking_no_autofree: void (void)
+talloc_find_parent_byname: void *(const void *, const char *)
+talloc_free_children: void (void *)
+talloc_get_name: const char *(const void *)
+talloc_get_size: size_t (const void *)
+talloc_increase_ref_count: int (const void *)
+talloc_init: void *(const char *, ...)
+talloc_is_parent: int (const void *, const void *)
+talloc_named: void *(const void *, size_t, const char *, ...)
+talloc_named_const: void *(const void *, size_t, const char *)
+talloc_parent: void *(const void *)
+talloc_parent_name: const char *(const void *)
+talloc_pool: void *(const void *, size_t)
+talloc_realloc_fn: void *(const void *, void *, size_t)
+talloc_reference_count: size_t (const void *)
+talloc_reparent: void *(const void *, const void *, const void *)
+talloc_report: void (const void *, FILE *)
+talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
+talloc_report_depth_file: void (const void *, int, int, FILE *)
+talloc_report_full: void (const void *, FILE *)
+talloc_set_abort_fn: void (void (*)(const char *))
+talloc_set_log_fn: void (void (*)(const char *))
+talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
+talloc_set_name: const char *(const void *, const char *, ...)
+talloc_set_name_const: void (const void *, const char *)
+talloc_show_parents: void (const void *, FILE *)
+talloc_strdup: char *(const void *, const char *)
+talloc_strdup_append: char *(char *, const char *)
+talloc_strdup_append_buffer: char *(char *, const char *)
+talloc_strndup: char *(const void *, const char *, size_t)
+talloc_strndup_append: char *(char *, const char *, size_t)
+talloc_strndup_append_buffer: char *(char *, const char *, size_t)
+talloc_test_get_magic: int (void)
+talloc_total_blocks: size_t (const void *)
+talloc_total_size: size_t (const void *)
+talloc_unlink: int (const void *, void *)
+talloc_vasprintf: char *(const void *, const char *, va_list)
+talloc_vasprintf_append: char *(char *, const char *, va_list)
+talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
+talloc_version_major: int (void)
+talloc_version_minor: int (void)
diff -Nru tevent-0.9.25/lib/talloc/talloc.c tevent-0.9.28/lib/talloc/talloc.c
--- tevent-0.9.25/lib/talloc/talloc.c	2015-03-10 12:28:31.000000000 +0000
+++ tevent-0.9.28/lib/talloc/talloc.c	2016-02-26 03:24:44.000000000 +0000
@@ -33,6 +33,10 @@
 #include "replace.h"
 #include "talloc.h"
 
+#ifdef HAVE_SYS_AUXV_H
+#include <sys/auxv.h>
+#endif
+
 #ifdef TALLOC_BUILD_VERSION_MAJOR
 #if (TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR)
 #error "TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR"
@@ -60,20 +64,26 @@
 
 
 #define MAX_TALLOC_SIZE 0x10000000
-#define TALLOC_MAGIC_BASE 0xe814ec70
-#define TALLOC_MAGIC ( \
-	TALLOC_MAGIC_BASE + \
-	(TALLOC_VERSION_MAJOR << 12) + \
-	(TALLOC_VERSION_MINOR << 4) \
-)
 
 #define TALLOC_FLAG_FREE 0x01
 #define TALLOC_FLAG_LOOP 0x02
 #define TALLOC_FLAG_POOL 0x04		/* This is a talloc pool */
 #define TALLOC_FLAG_POOLMEM 0x08	/* This is allocated in a pool */
 
+/*
+ * Bits above this are random, used to make it harder to fake talloc
+ * headers during an attack.  Try not to change this without good reason.
+ */
+#define TALLOC_FLAG_MASK 0x0F
+
 #define TALLOC_MAGIC_REFERENCE ((const char *)1)
 
+#define TALLOC_MAGIC_BASE 0xe814ec70
+static unsigned int talloc_magic = (
+	TALLOC_MAGIC_BASE +
+	(TALLOC_VERSION_MAJOR << 12) +
+	(TALLOC_VERSION_MINOR << 4));
+
 /* by default we abort when given a bad pointer (such as when talloc_free() is called
    on a pointer that came from malloc() */
 #ifndef TALLOC_ABORT
@@ -249,13 +259,13 @@
 struct talloc_pool_hdr;
 
 struct talloc_chunk {
+	unsigned flags;
 	struct talloc_chunk *next, *prev;
 	struct talloc_chunk *parent, *child;
 	struct talloc_reference_handle *refs;
 	talloc_destructor_t destructor;
 	const char *name;
 	size_t size;
-	unsigned flags;
 
 	/*
 	 * limit semantics:
@@ -290,6 +300,11 @@
 	return TALLOC_VERSION_MINOR;
 }
 
+_PUBLIC_ int talloc_test_get_magic(void)
+{
+	return talloc_magic;
+}
+
 static void (*talloc_log_fn)(const char *message);
 
 _PUBLIC_ void talloc_set_log_fn(void (*log_fn)(const char *message))
@@ -297,6 +312,50 @@
 	talloc_log_fn = log_fn;
 }
 
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+void talloc_lib_init(void) __attribute__((constructor));
+void talloc_lib_init(void)
+{
+	uint32_t random_value;
+#if defined(HAVE_GETAUXVAL) && defined(AT_RANDOM)
+	uint8_t *p;
+	/*
+	 * Use the kernel-provided random values used for
+	 * ASLR.  This won't change per-exec, which is ideal for us
+	 */
+	p = (uint8_t *) getauxval(AT_RANDOM);
+	if (p) {
+		/*
+		 * We get 16 bytes from getauxval.  By calling rand(),
+		 * a totally insecure PRNG, but one that will
+		 * deterministically have a different value when called
+		 * twice, we ensure that if two talloc-like libraries
+		 * are somehow loaded in the same address space, that
+		 * because we choose different bytes, we will keep the
+		 * protection against collision of multiple talloc
+		 * libs.
+		 *
+		 * This protection is important because the effects of
+		 * passing a talloc pointer from one to the other may
+		 * be very hard to determine.
+		 */
+		int offset = rand() % (16 - sizeof(random_value));
+		memcpy(&random_value, p + offset, sizeof(random_value));
+	} else
+#endif
+	{
+		/*
+		 * Otherwise, hope the location we are loaded in
+		 * memory is randomised by someone else
+		 */
+		random_value = ((uintptr_t)talloc_lib_init & 0xFFFFFFFF);
+	}
+	talloc_magic = random_value & ~TALLOC_FLAG_MASK;
+}
+#else
+#warning "No __attribute__((constructor)) support found on this platform, additional talloc security measures not available"
+#endif
+
 static void talloc_log(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
 static void talloc_log(const char *fmt, ...)
 {
@@ -345,12 +404,6 @@
 
 static void talloc_abort_magic(unsigned magic)
 {
-	unsigned striped = magic - TALLOC_MAGIC_BASE;
-	unsigned major = (striped & 0xFFFFF000) >> 12;
-	unsigned minor = (striped & 0x00000FF0) >> 4;
-	talloc_log("Bad talloc magic[0x%08X/%u/%u] expected[0x%08X/%u/%u]\n",
-		   magic, major, minor,
-		   TALLOC_MAGIC, TALLOC_VERSION_MAJOR, TALLOC_VERSION_MINOR);
 	talloc_abort("Bad talloc magic value - wrong talloc version used/mixed");
 }
 
@@ -369,9 +422,9 @@
 {
 	const char *pp = (const char *)ptr;
 	struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
-	if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) {
-		if ((tc->flags & (~0xFFF)) == TALLOC_MAGIC_BASE) {
-			talloc_abort_magic(tc->flags & (~0xF));
+	if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~TALLOC_FLAG_MASK)) != talloc_magic)) {
+		if ((tc->flags & (~0xF)) == talloc_magic) {
+			talloc_abort_magic(tc->flags & (~TALLOC_FLAG_MASK));
 			return NULL;
 		}
 
@@ -561,7 +614,7 @@
 
 	pool_hdr->end = (void *)((char *)pool_hdr->end + chunk_size);
 
-	result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
+	result->flags = talloc_magic | TALLOC_FLAG_POOLMEM;
 	result->pool = pool_hdr;
 
 	pool_hdr->object_count++;
@@ -617,7 +670,7 @@
 			return NULL;
 		}
 		tc = (struct talloc_chunk *)(ptr + prefix_len);
-		tc->flags = TALLOC_MAGIC;
+		tc->flags = talloc_magic;
 		tc->pool  = NULL;
 
 		talloc_memlimit_grow(limit, total_len);
diff -Nru tevent-0.9.25/lib/talloc/talloc.h tevent-0.9.28/lib/talloc/talloc.h
--- tevent-0.9.25/lib/talloc/talloc.h	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/lib/talloc/talloc.h	2016-02-26 03:24:44.000000000 +0000
@@ -47,6 +47,8 @@
 
 int talloc_version_major(void);
 int talloc_version_minor(void);
+/* This is mostly useful only for testing */
+int talloc_test_get_magic(void);
 
 /**
  * @brief Define a talloc parent type
@@ -749,7 +751,7 @@
  * @brief Safely turn a void pointer into a typed pointer.
  *
  * This macro is used together with talloc(mem_ctx, struct foo). If you had to
- * assing the talloc chunk pointer to some void pointer variable,
+ * assign the talloc chunk pointer to some void pointer variable,
  * talloc_get_type_abort() is the recommended way to get the convert the void
  * pointer back to a typed pointer.
  *
diff -Nru tevent-0.9.25/lib/talloc/test_magic_differs_helper.c tevent-0.9.28/lib/talloc/test_magic_differs_helper.c
--- tevent-0.9.25/lib/talloc/test_magic_differs_helper.c	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/test_magic_differs_helper.c	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "talloc.h"
+
+/*
+ * This program is called by a testing shell script in order to ensure that
+ * if the library is loaded into different processes it uses different magic
+ * values in order to thwart security attacks.
+ */
+int main(int argc, char *argv[]) {
+	printf("%i\n", talloc_test_get_magic());
+	return 0;
+}
diff -Nru tevent-0.9.25/lib/talloc/test_magic_differs.sh tevent-0.9.28/lib/talloc/test_magic_differs.sh
--- tevent-0.9.25/lib/talloc/test_magic_differs.sh	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/lib/talloc/test_magic_differs.sh	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,14 @@
+#!/bin/sh
+# This test ensures that two different talloc processes do not use the same
+# magic value to lessen the opportunity for transferrable attacks.
+
+echo "test: magic differs"
+
+if [
+	"`./talloc_test_magic_differs_helper`" != "`./talloc_test_magic_differs_helper`"
+]; then
+	echo "failure: magic remained the same between executions"
+	exit 1
+fi
+
+echo "success: magic differs"
diff -Nru tevent-0.9.25/lib/talloc/testsuite.c tevent-0.9.28/lib/talloc/testsuite.c
--- tevent-0.9.25/lib/talloc/testsuite.c	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/lib/talloc/testsuite.c	2016-02-26 03:24:44.000000000 +0000
@@ -31,6 +31,9 @@
 #include <pthread.h>
 #endif
 
+#include <unistd.h>
+#include <sys/wait.h>
+
 #include "talloc_testsuite.h"
 
 static struct timeval timeval_current(void)
@@ -1747,6 +1750,7 @@
 		ret = pthread_cond_wait(&condvar, &mtx);
 		if (ret != 0) {
 			talloc_free(top_ctx);
+			pthread_mutex_unlock(&mtx);
 			return NULL;
 		}
 	}
@@ -1827,6 +1831,7 @@
 				printf("pthread_cond_wait %d failed (%d)\n", i,
 					ret);
 				talloc_free(mem_ctx);
+				pthread_mutex_unlock(&mtx);
 				return false;
 			}
 		}
@@ -1850,6 +1855,70 @@
 }
 #endif
 
+static void test_magic_protection_abort(const char *reason)
+{
+	/* exit with errcode 42 to communicate successful test to the parent process */
+	if (strcmp(reason, "Bad talloc magic value - unknown value") == 0) {
+		_exit(42);
+	} else {
+		printf("talloc aborted for an unexpected reason\n");
+	}
+}
+
+static bool test_magic_protection(void)
+{
+	void *pool = talloc_pool(NULL, 1024);
+	int *p1, *p2;
+	pid_t pid;
+	int exit_status;
+
+	printf("test: magic_protection\n");
+	p1 = talloc(pool, int);
+	p2 = talloc(pool, int);
+
+	/* To avoid complaints from the compiler assign values to the p1 & p2. */
+	*p1 = 6;
+	*p2 = 9;
+
+	pid = fork();
+	if (pid == 0) {
+		talloc_set_abort_fn(test_magic_protection_abort);
+
+		/*
+		 * Simulate a security attack
+		 * by triggering a buffer overflow in memset to overwrite the
+		 * constructor in the next pool chunk.
+		 *
+		 * Real attacks would attempt to set a real destructor.
+		 */
+		memset(p1, '\0', 32);
+
+		/* Then the attack takes effect when the memory's freed. */
+		talloc_free(pool);
+
+		/* Never reached. Make compilers happy */
+		return true;
+	}
+
+	while (wait(&exit_status) != pid);
+
+	if (!WIFEXITED(exit_status)) {
+		printf("Child exited through unexpected abnormal means\n");
+		return false;
+	}
+	if (WEXITSTATUS(exit_status) != 42) {
+		printf("Child exited with wrong exit status\n");
+		return false;
+	}
+	if (WIFSIGNALED(exit_status)) {
+		printf("Child recieved unexpected signal\n");
+		return false;
+	}
+
+	printf("success: magic_protection\n");
+	return true;
+}
+
 static void test_reset(void)
 {
 	talloc_set_log_fn(test_log_stdout);
@@ -1932,6 +2001,8 @@
 	}
 	test_reset();
 	ret &= test_autofree();
+	test_reset();
+	ret &= test_magic_protection();
 
 	test_reset();
 	talloc_disable_null_tracking();
diff -Nru tevent-0.9.25/lib/talloc/wscript tevent-0.9.28/lib/talloc/wscript
--- tevent-0.9.25/lib/talloc/wscript	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/lib/talloc/wscript	2016-02-26 03:24:44.000000000 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'talloc'
-VERSION = '2.1.2'
+VERSION = '2.1.5'
 
 
 blddir = 'bin'
@@ -66,6 +66,9 @@
             Logs.warn('Disabling pytalloc-util as python devel libs not found')
             conf.env.disable_python = True
 
+    conf.CHECK_HEADERS('sys/auxv.h')
+    conf.CHECK_FUNCS('getauxval')
+
     conf.SAMBA_CONFIG_H()
 
     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
@@ -97,6 +100,10 @@
                          testsuite_deps,
                          install=False)
 
+        bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
+                         'test_magic_differs_helper.c',
+                         'talloc', install=False)
+
     else:
         private_library = True
 
@@ -109,7 +116,7 @@
                           abi_match='talloc* _talloc*',
                           hide_symbols=True,
                           vnum=VERSION,
-                          public_headers='talloc.h',
+                          public_headers=('' if private_library else 'talloc.h'),
                           pc_files='talloc.pc',
                           public_headers_install=not private_library,
                           private_library=private_library,
@@ -128,7 +135,7 @@
                 abi_directory='ABI',
                 abi_match='pytalloc_*',
                 private_library=private_library,
-                public_headers='pytalloc.h',
+                public_headers=('' if private_library else 'pytalloc.h'),
                 pc_files='pytalloc-util.pc'
                 )
             bld.SAMBA_PYTHON('pytalloc',
@@ -151,9 +158,14 @@
     cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
     ret = samba_utils.RUN_COMMAND(cmd)
     print("testsuite returned %d" % ret)
+    magic_cmd = os.path.join(srcdir, 'lib', 'talloc',
+                             'test_magic_differs.sh')
+
+    magic_ret = samba_utils.RUN_COMMAND(magic_cmd)
+    print("magic differs test returned %d" % magic_ret)
     pyret = samba_utils.RUN_PYTHON_TESTS(['test_pytalloc.py'])
     print("python testsuite returned %d" % pyret)
-    sys.exit(ret or pyret)
+    sys.exit(ret or magic_ret or pyret)
 
 def dist():
     '''makes a tarball for distribution'''
diff -Nru tevent-0.9.25/testsuite.c tevent-0.9.28/testsuite.c
--- tevent-0.9.25/testsuite.c	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/testsuite.c	2016-02-26 03:24:44.000000000 +0000
@@ -808,6 +808,327 @@
 	return true;
 }
 
+#define NUM_TEVENT_THREADS 100
+
+/* Ugly, but needed for torture_comment... */
+static struct torture_context *thread_test_ctx;
+static pthread_t thread_map[NUM_TEVENT_THREADS];
+static unsigned thread_counter;
+
+/* Called in master thread context */
+static void callback_nowait(struct tevent_context *ev,
+				struct tevent_immediate *im,
+				void *private_ptr)
+{
+	pthread_t *thread_id_ptr =
+		talloc_get_type_abort(private_ptr, pthread_t);
+	unsigned i;
+
+	for (i = 0; i < NUM_TEVENT_THREADS; i++) {
+		if (pthread_equal(*thread_id_ptr,
+				thread_map[i])) {
+			break;
+		}
+	}
+	torture_comment(thread_test_ctx,
+			"Callback %u from thread %u\n",
+			thread_counter,
+			i);
+	thread_counter++;
+}
+
+/* Blast the master tevent_context with a callback, no waiting. */
+static void *thread_fn_nowait(void *private_ptr)
+{
+	struct tevent_thread_proxy *master_tp =
+		talloc_get_type_abort(private_ptr, struct tevent_thread_proxy);
+	struct tevent_immediate *im;
+	pthread_t *thread_id_ptr;
+
+	im = tevent_create_immediate(NULL);
+	if (im == NULL) {
+		return NULL;
+	}
+	thread_id_ptr = talloc(NULL, pthread_t);
+	if (thread_id_ptr == NULL) {
+		return NULL;
+	}
+	*thread_id_ptr = pthread_self();
+
+	tevent_thread_proxy_schedule(master_tp,
+				&im,
+				callback_nowait,
+				&thread_id_ptr);
+	return NULL;
+}
+
+static void timeout_fn(struct tevent_context *ev,
+			struct tevent_timer *te,
+			struct timeval tv, void *p)
+{
+	thread_counter = NUM_TEVENT_THREADS * 10;
+}
+
+static bool test_multi_tevent_threaded(struct torture_context *test,
+					const void *test_data)
+{
+	unsigned i;
+	struct tevent_context *master_ev;
+	struct tevent_thread_proxy *tp;
+
+	talloc_disable_null_tracking();
+
+	/* Ugly global stuff. */
+	thread_test_ctx = test;
+	thread_counter = 0;
+
+	master_ev = tevent_context_init(NULL);
+	if (master_ev == NULL) {
+		return false;
+	}
+	tevent_set_debug_stderr(master_ev);
+
+	tp = tevent_thread_proxy_create(master_ev);
+	if (tp == NULL) {
+		torture_fail(test,
+			talloc_asprintf(test,
+				"tevent_thread_proxy_create failed\n"));
+		talloc_free(master_ev);
+		return false;
+	}
+
+	for (i = 0; i < NUM_TEVENT_THREADS; i++) {
+		int ret = pthread_create(&thread_map[i],
+				NULL,
+				thread_fn_nowait,
+				tp);
+		if (ret != 0) {
+			torture_fail(test,
+				talloc_asprintf(test,
+					"Failed to create thread %i, %d\n",
+					i, ret));
+			return false;
+		}
+	}
+
+	/* Ensure we don't wait more than 10 seconds. */
+	tevent_add_timer(master_ev,
+			master_ev,
+			timeval_current_ofs(10,0),
+			timeout_fn,
+			NULL);
+
+	while (thread_counter < NUM_TEVENT_THREADS) {
+		int ret = tevent_loop_once(master_ev);
+		torture_assert(test, ret == 0, "tevent_loop_once failed");
+	}
+
+	torture_assert(test, thread_counter == NUM_TEVENT_THREADS,
+		"thread_counter fail\n");
+
+	talloc_free(master_ev);
+	return true;
+}
+
+struct reply_state {
+	struct tevent_thread_proxy *reply_tp;
+	pthread_t thread_id;
+	int *p_finished;
+};
+
+static void thread_timeout_fn(struct tevent_context *ev,
+			struct tevent_timer *te,
+			struct timeval tv, void *p)
+{
+	int *p_finished = (int *)p;
+
+	*p_finished = 2;
+}
+
+/* Called in child-thread context */
+static void thread_callback(struct tevent_context *ev,
+				struct tevent_immediate *im,
+				void *private_ptr)
+{
+	struct reply_state *rsp =
+		talloc_get_type_abort(private_ptr, struct reply_state);
+
+	talloc_steal(ev, rsp);
+	*rsp->p_finished = 1;
+}
+
+/* Called in master thread context */
+static void master_callback(struct tevent_context *ev,
+				struct tevent_immediate *im,
+				void *private_ptr)
+{
+	struct reply_state *rsp =
+		talloc_get_type_abort(private_ptr, struct reply_state);
+	unsigned i;
+
+	talloc_steal(ev, rsp);
+
+	for (i = 0; i < NUM_TEVENT_THREADS; i++) {
+		if (pthread_equal(rsp->thread_id,
+				thread_map[i])) {
+			break;
+		}
+	}
+	torture_comment(thread_test_ctx,
+			"Callback %u from thread %u\n",
+			thread_counter,
+			i);
+	/* Now reply to the thread ! */
+	tevent_thread_proxy_schedule(rsp->reply_tp,
+				&im,
+				thread_callback,
+				&rsp);
+
+	thread_counter++;
+}
+
+static void *thread_fn_1(void *private_ptr)
+{
+	struct tevent_thread_proxy *master_tp =
+		talloc_get_type_abort(private_ptr, struct tevent_thread_proxy);
+	struct tevent_thread_proxy *tp;
+	struct tevent_immediate *im;
+	struct tevent_context *ev;
+	struct reply_state *rsp;
+	int finished = 0;
+	int ret;
+
+	ev = tevent_context_init(NULL);
+	if (ev == NULL) {
+		return NULL;
+	}
+
+	tp = tevent_thread_proxy_create(ev);
+	if (tp == NULL) {
+		talloc_free(ev);
+		return NULL;
+	}
+
+	im = tevent_create_immediate(ev);
+	if (im == NULL) {
+		talloc_free(ev);
+		return NULL;
+	}
+
+	rsp = talloc(ev, struct reply_state);
+	if (rsp == NULL) {
+		talloc_free(ev);
+		return NULL;
+	}
+
+	rsp->thread_id = pthread_self();
+	rsp->reply_tp = tp;
+	rsp->p_finished = &finished;
+
+	/* Introduce a little randomness into the mix.. */
+	usleep(random() % 7000);
+
+	tevent_thread_proxy_schedule(master_tp,
+				&im,
+				master_callback,
+				&rsp);
+
+	/* Ensure we don't wait more than 10 seconds. */
+	tevent_add_timer(ev,
+			ev,
+			timeval_current_ofs(10,0),
+			thread_timeout_fn,
+			&finished);
+
+	while (finished == 0) {
+		ret = tevent_loop_once(ev);
+		assert(ret == 0);
+	}
+
+	if (finished > 1) {
+		/* Timeout ! */
+		abort();
+	}
+
+	/*
+	 * NB. We should talloc_free(ev) here, but if we do
+	 * we currently get hit by helgrind Fix #323432
+	 * "When calling pthread_cond_destroy or pthread_mutex_destroy
+	 * with initializers as argument Helgrind (incorrectly) reports errors."
+	 *
+	 * http://valgrind.10908.n7.nabble.com/Helgrind-3-9-0-false-positive-
+	 * with-pthread-mutex-destroy-td47757.html
+	 *
+	 * Helgrind doesn't understand that the request/reply
+	 * messages provide synchronization between the lock/unlock
+	 * in tevent_thread_proxy_schedule(), and the pthread_destroy()
+	 * when the struct tevent_thread_proxy object is talloc_free'd.
+	 *
+	 * As a work-around for now return ev for the parent thread to free.
+	 */
+	return ev;
+}
+
+static bool test_multi_tevent_threaded_1(struct torture_context *test,
+					const void *test_data)
+{
+	unsigned i;
+	struct tevent_context *master_ev;
+	struct tevent_thread_proxy *master_tp;
+	int ret;
+
+	talloc_disable_null_tracking();
+
+	/* Ugly global stuff. */
+	thread_test_ctx = test;
+	thread_counter = 0;
+
+	master_ev = tevent_context_init(NULL);
+	if (master_ev == NULL) {
+		return false;
+	}
+	tevent_set_debug_stderr(master_ev);
+
+	master_tp = tevent_thread_proxy_create(master_ev);
+	if (master_tp == NULL) {
+		torture_fail(test,
+			talloc_asprintf(test,
+				"tevent_thread_proxy_create failed\n"));
+		talloc_free(master_ev);
+		return false;
+	}
+
+	for (i = 0; i < NUM_TEVENT_THREADS; i++) {
+		ret = pthread_create(&thread_map[i],
+				NULL,
+				thread_fn_1,
+				master_tp);
+		if (ret != 0) {
+			torture_fail(test,
+				talloc_asprintf(test,
+					"Failed to create thread %i, %d\n",
+					i, ret));
+				return false;
+		}
+	}
+
+	while (thread_counter < NUM_TEVENT_THREADS) {
+		ret = tevent_loop_once(master_ev);
+		torture_assert(test, ret == 0, "tevent_loop_once failed");
+	}
+
+	/* Wait for all the threads to finish - join 'em. */
+	for (i = 0; i < NUM_TEVENT_THREADS; i++) {
+		void *retval;
+		ret = pthread_join(thread_map[i], &retval);
+		torture_assert(test, ret == 0, "pthread_join failed");
+		/* Free the child thread event context. */
+		talloc_free(retval);
+	}
+
+	talloc_free(master_ev);
+	return true;
+}
 #endif
 
 struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
@@ -841,6 +1162,15 @@
 	torture_suite_add_simple_tcase_const(suite, "threaded_poll_mt",
 					     test_event_context_threaded,
 					     NULL);
+
+	torture_suite_add_simple_tcase_const(suite, "multi_tevent_threaded",
+					     test_multi_tevent_threaded,
+					     NULL);
+
+	torture_suite_add_simple_tcase_const(suite, "multi_tevent_threaded_1",
+					     test_multi_tevent_threaded_1,
+					     NULL);
+
 #endif
 
 	return suite;
diff -Nru tevent-0.9.25/tevent_epoll.c tevent-0.9.28/tevent_epoll.c
--- tevent-0.9.25/tevent_epoll.c	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/tevent_epoll.c	2016-02-26 03:24:44.000000000 +0000
@@ -216,7 +216,7 @@
 
 /*
   reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
+  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
   demonstration of why this is needed
  */
 static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
@@ -661,7 +661,7 @@
 	}
 
 	for (i=0;i<ret;i++) {
-		struct tevent_fd *fde = talloc_get_type(events[i].data.ptr, 
+		struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
 						       struct tevent_fd);
 		uint16_t flags = 0;
 		struct tevent_fd *mpx_fde = NULL;
@@ -888,7 +888,7 @@
 }
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
 static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
 {
diff -Nru tevent-0.9.25/tevent.h tevent-0.9.28/tevent.h
--- tevent-0.9.25/tevent.h	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/tevent.h	2016-02-26 03:24:44.000000000 +0000
@@ -39,6 +39,7 @@
 struct tevent_timer;
 struct tevent_immediate;
 struct tevent_signal;
+struct tevent_thread_proxy;
 
 /**
  * @defgroup tevent The tevent API
@@ -1698,6 +1699,57 @@
 				   bool begin,
 				   void *stack_ptr,
 				   const char *location);
+
+/**
+ * @brief Create a tevent_thread_proxy for message passing between threads.
+ *
+ * The tevent_context must have been allocated on the NULL
+ * talloc context, and talloc_disable_null_tracking() must
+ * have been called.
+ *
+ * @param[in]  dest_ev_ctx      The tevent_context to receive events.
+ *
+ * @return              An allocated tevent_thread_proxy, NULL on error.
+ *                      If tevent was compiled without PTHREAD support
+ *                      NULL is always returned and errno set to ENOSYS.
+ *
+ * @see tevent_thread_proxy_schedule()
+ */
+struct tevent_thread_proxy *tevent_thread_proxy_create(
+                struct tevent_context *dest_ev_ctx);
+
+/**
+ * @brief Schedule an immediate event on an event context from another thread.
+ *
+ * Causes dest_ev_ctx, being run by another thread, to receive an
+ * immediate event calling the handler with the *pp_private parameter.
+ *
+ * *pp_im must be a pointer to an immediate event talloced on a context owned
+ * by the calling thread, or the NULL context. Ownership will
+ * be transferred to the tevent_thread_proxy and *pp_im will be returned as NULL.
+ *
+ * *pp_private_data must be a talloced area of memory with no destructors.
+ * Ownership of this memory will be transferred to the tevent library and
+ * *pp_private_data will be set to NULL on successful completion of
+ * the call. Set pp_private to NULL if no parameter transfer
+ * needed (a pure callback). This is an asynchronous request, caller
+ * does not wait for callback to be completed before returning.
+ *
+ * @param[in]  tp               The tevent_thread_proxy to use.
+ *
+ * @param[in]  pp_im            Pointer to immediate event pointer.
+ *
+ * @param[in]  handler          The function that will be called.
+ *
+ * @param[in]  pp_private_data  The talloced memory to transfer.
+ *
+ * @see tevent_thread_proxy_create()
+ */
+void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
+				  struct tevent_immediate **pp_im,
+				  tevent_immediate_handler_t handler,
+				  void *pp_private_data);
+
 #ifdef TEVENT_DEPRECATED
 #ifndef _DEPRECATED_
 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
diff -Nru tevent-0.9.25/tevent_immediate.c tevent-0.9.28/tevent_immediate.c
--- tevent-0.9.25/tevent_immediate.c	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/tevent_immediate.c	2016-02-26 03:24:44.000000000 +0000
@@ -88,7 +88,7 @@
 	im->cancel_fn		= NULL;
 	im->additional_data	= NULL;
 
-	DLIST_ADD_END(ev->immediate_events, im, struct tevent_immediate *);
+	DLIST_ADD_END(ev->immediate_events, im);
 	talloc_set_destructor(im, tevent_common_immediate_destructor);
 
 	tevent_debug(ev, TEVENT_DEBUG_TRACE,
diff -Nru tevent-0.9.25/tevent_poll.c tevent-0.9.28/tevent_poll.c
--- tevent-0.9.25/tevent_poll.c	2014-10-01 09:22:21.000000000 +0000
+++ tevent-0.9.28/tevent_poll.c	2016-02-26 03:24:44.000000000 +0000
@@ -498,6 +498,7 @@
 	int timeout = -1;
 	int poll_errno;
 	struct tevent_fd *fde = NULL;
+	struct tevent_fd *next = NULL;
 	unsigned i;
 
 	if (ev->signal_events && tevent_common_check_signal(ev)) {
@@ -542,11 +543,13 @@
 	   which ones and call the handler, being careful to allow
 	   the handler to remove itself when called */
 
-	for (fde = ev->fd_events; fde; fde = fde->next) {
+	for (fde = ev->fd_events; fde; fde = next) {
 		uint64_t idx = fde->additional_flags;
 		struct pollfd *pfd;
 		uint16_t flags = 0;
 
+		next = fde->next;
+
 		if (idx == UINT64_MAX) {
 			continue;
 		}
@@ -598,7 +601,7 @@
 		 */
 		flags &= fde->flags;
 		if (flags != 0) {
-			DLIST_DEMOTE(ev->fd_events, fde, struct tevent_fd);
+			DLIST_DEMOTE(ev->fd_events, fde);
 			fde->handler(ev, fde, flags, fde->private_data);
 			return 0;
 		}
diff -Nru tevent-0.9.25/tevent_port.c tevent-0.9.28/tevent_port.c
--- tevent-0.9.25/tevent_port.c	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/tevent_port.c	2016-02-26 03:24:44.000000000 +0000
@@ -496,10 +496,24 @@
 		return 0;
 	}
 
-	if (ret == -1 && port_errno == ETIME && tvalp) {
-		/* we don't care about a possible delay here */
-		tevent_common_loop_timer_delay(ev);
-		return 0;
+	if (ret == -1 && port_errno == ETIME) {
+		/*
+		 * If errno is set to ETIME it is possible that we still got an event.
+		 * In that case we need to go through the processing loop so that we
+		 * reassociate the received event with the port or the association will
+		 * be lost so check the value of nget is 0 before returning.
+		 */
+		if (nget == 0) {
+			/* we don't care about a possible delay here */
+			tevent_common_loop_timer_delay(ev);
+			return 0;
+		}
+		/*
+		 * Set the return value to 0 since we do not actually have an error and we
+		 * do have events that need to be processed.  This keeps us from getting
+		 * caught in the generic error test.
+		 */
+		ret = 0;
 	}
 
 	if (ret == -1) {
diff -Nru tevent-0.9.25/tevent_queue.c tevent-0.9.28/tevent_queue.c
--- tevent-0.9.25/tevent_queue.c	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/tevent_queue.c	2016-02-26 03:24:44.000000000 +0000
@@ -195,7 +195,7 @@
 		allow_direct = false;
 	}
 
-	DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
+	DLIST_ADD_END(queue->list, e);
 	queue->length++;
 	talloc_set_destructor(e, tevent_queue_entry_destructor);
 
diff -Nru tevent-0.9.25/tevent_select.c tevent-0.9.28/tevent_select.c
--- tevent-0.9.25/tevent_select.c	2014-10-01 09:22:21.000000000 +0000
+++ tevent-0.9.28/tevent_select.c	2016-02-26 03:24:44.000000000 +0000
@@ -219,7 +219,7 @@
 				flags |= TEVENT_FD_WRITE;
 			}
 			if (flags) {
-				DLIST_DEMOTE(select_ev->ev->fd_events, fde, struct tevent_fd);
+				DLIST_DEMOTE(select_ev->ev->fd_events, fde);
 				fde->handler(select_ev->ev, fde, flags, fde->private_data);
 				break;
 			}
diff -Nru tevent-0.9.25/tevent_signal.c tevent-0.9.28/tevent_signal.c
--- tevent-0.9.25/tevent_signal.c	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/tevent_signal.c	2016-02-26 03:24:44.000000000 +0000
@@ -212,6 +212,7 @@
 		/* restore old handler, if any */
 		if (sig_state->oldact[se->signum]) {
 			sigaction(se->signum, sig_state->oldact[se->signum], NULL);
+			talloc_free(sig_state->oldact[se->signum]);
 			sig_state->oldact[se->signum] = NULL;
 		}
 #ifdef SA_SIGINFO
@@ -342,6 +343,8 @@
 			return NULL;
 		}
 		if (sigaction(signum, &act, sig_state->oldact[signum]) == -1) {
+			talloc_free(sig_state->oldact[signum]);
+			sig_state->oldact[signum] = NULL;
 			talloc_free(se);
 			return NULL;
 		}
@@ -505,6 +508,7 @@
 	if (sig_state->sig_handlers[se->signum] == NULL) {
 		if (sig_state->oldact[se->signum]) {
 			sigaction(se->signum, sig_state->oldact[se->signum], NULL);
+			talloc_free(sig_state->oldact[se->signum]);
 			sig_state->oldact[se->signum] = NULL;
 		}
 	}
diff -Nru tevent-0.9.25/tevent_threads.c tevent-0.9.28/tevent_threads.c
--- tevent-0.9.25/tevent_threads.c	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/tevent_threads.c	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,370 @@
+/*
+   tevent event library.
+
+   Copyright (C) Jeremy Allison 2015
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "talloc.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+#if defined(HAVE_PTHREAD)
+#include <pthread.h>
+
+struct tevent_immediate_list {
+	struct tevent_immediate_list *next, *prev;
+	tevent_immediate_handler_t handler;
+	struct tevent_immediate *im;
+	void *private_ptr;
+};
+
+struct tevent_thread_proxy {
+	pthread_mutex_t mutex;
+	struct tevent_context *dest_ev_ctx;
+	int read_fd;
+	int write_fd;
+	struct tevent_fd *pipe_read_fde;
+	/* Pending events list. */
+	struct tevent_immediate_list *im_list;
+	/* Completed events list. */
+	struct tevent_immediate_list *tofree_im_list;
+	struct tevent_immediate *free_im;
+};
+
+static void free_im_list(struct tevent_immediate_list **pp_list_head)
+{
+	struct tevent_immediate_list *im_entry = NULL;
+	struct tevent_immediate_list *im_next = NULL;
+
+	for (im_entry = *pp_list_head; im_entry; im_entry = im_next) {
+		im_next = im_entry->next;
+		DLIST_REMOVE(*pp_list_head, im_entry);
+		TALLOC_FREE(im_entry);
+	}
+}
+
+static void free_list_handler(struct tevent_context *ev,
+				struct tevent_immediate *im,
+				void *private_ptr)
+{
+	struct tevent_thread_proxy *tp =
+		talloc_get_type_abort(private_ptr, struct tevent_thread_proxy);
+	int ret;
+
+	ret = pthread_mutex_lock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return;
+	}
+
+	free_im_list(&tp->tofree_im_list);
+
+	ret = pthread_mutex_unlock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return;
+	}
+}
+
+static void schedule_immediate_functions(struct tevent_thread_proxy *tp)
+{
+	struct tevent_immediate_list *im_entry = NULL;
+	struct tevent_immediate_list *im_next = NULL;
+
+	for (im_entry = tp->im_list; im_entry; im_entry = im_next) {
+		im_next = im_entry->next;
+		DLIST_REMOVE(tp->im_list, im_entry);
+
+		tevent_schedule_immediate(im_entry->im,
+					tp->dest_ev_ctx,
+					im_entry->handler,
+					im_entry->private_ptr);
+
+		/* Move from pending list to free list. */
+		DLIST_ADD(tp->tofree_im_list, im_entry);
+	}
+	if (tp->tofree_im_list != NULL) {
+		/*
+		 * Once the current immediate events
+		 * are processed, we need to reshedule
+		 * ourselves to free them. This works
+		 * as tevent_schedule_immediate()
+		 * always adds events to the *END* of
+		 * the immediate events list.
+		 */
+		tevent_schedule_immediate(tp->free_im,
+					tp->dest_ev_ctx,
+					free_list_handler,
+					tp);
+	}
+}
+
+static void pipe_read_handler(struct tevent_context *ev,
+				struct tevent_fd *fde,
+				uint16_t flags,
+				void *private_ptr)
+{
+	struct tevent_thread_proxy *tp =
+		talloc_get_type_abort(private_ptr, struct tevent_thread_proxy);
+	ssize_t len = 64;
+	int ret;
+
+	ret = pthread_mutex_lock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return;
+	}
+
+	/*
+	 * Clear out all data in the pipe. We
+	 * don't really care if this returns -1.
+	 */
+	while (len == 64) {
+		char buf[64];
+		len = read(tp->read_fd, buf, 64);
+	};
+
+	schedule_immediate_functions(tp);
+
+	ret = pthread_mutex_unlock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return;
+	}
+}
+
+static int tevent_thread_proxy_destructor(struct tevent_thread_proxy *tp)
+{
+	int ret;
+
+	ret = pthread_mutex_lock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return 0;
+	}
+
+	TALLOC_FREE(tp->pipe_read_fde);
+
+	if (tp->read_fd != -1) {
+		(void)close(tp->read_fd);
+		tp->read_fd = -1;
+	}
+	if (tp->write_fd != -1) {
+		(void)close(tp->write_fd);
+		tp->write_fd = -1;
+	}
+
+	/* Hmmm. It's probably an error if we get here with
+	   any non-NULL immediate entries.. */
+
+	free_im_list(&tp->im_list);
+	free_im_list(&tp->tofree_im_list);
+
+	TALLOC_FREE(tp->free_im);
+
+	ret = pthread_mutex_unlock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return 0;
+	}
+
+	ret = pthread_mutex_destroy(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return 0;
+	}
+
+	return 0;
+}
+
+/*
+ * Create a struct that can be passed to other threads
+ * to allow them to signal the struct tevent_context *
+ * passed in.
+ */
+
+struct tevent_thread_proxy *tevent_thread_proxy_create(
+		struct tevent_context *dest_ev_ctx)
+{
+	int ret;
+	int pipefds[2];
+	struct tevent_thread_proxy *tp;
+
+	tp = talloc_zero(dest_ev_ctx, struct tevent_thread_proxy);
+	if (tp == NULL) {
+		return NULL;
+	}
+
+	ret = pthread_mutex_init(&tp->mutex, NULL);
+	if (ret != 0) {
+		goto fail;
+	}
+
+	tp->dest_ev_ctx = dest_ev_ctx;
+	tp->read_fd = -1;
+	tp->write_fd = -1;
+
+	talloc_set_destructor(tp, tevent_thread_proxy_destructor);
+
+	ret = pipe(pipefds);
+	if (ret == -1) {
+		goto fail;
+	}
+
+	tp->read_fd = pipefds[0];
+	tp->write_fd = pipefds[1];
+
+	ret = ev_set_blocking(pipefds[0], false);
+	if (ret != 0) {
+		goto fail;
+	}
+	ret = ev_set_blocking(pipefds[1], false);
+	if (ret != 0) {
+		goto fail;
+	}
+	if (!ev_set_close_on_exec(pipefds[0])) {
+		goto fail;
+	}
+	if (!ev_set_close_on_exec(pipefds[1])) {
+		goto fail;
+	}
+
+	tp->pipe_read_fde = tevent_add_fd(dest_ev_ctx,
+				tp,
+				tp->read_fd,
+				TEVENT_FD_READ,
+				pipe_read_handler,
+				tp);
+	if (tp->pipe_read_fde == NULL) {
+		goto fail;
+	}
+
+	/*
+	 * Create an immediate event to free
+	 * completed lists.
+	 */
+	tp->free_im = tevent_create_immediate(tp);
+	if (tp->free_im == NULL) {
+		goto fail;
+	}
+
+	return tp;
+
+  fail:
+
+	TALLOC_FREE(tp);
+	return NULL;
+}
+
+/*
+ * This function schedules an immediate event to be called with argument
+ * *pp_private in the thread context of dest_ev_ctx. Caller doesn't
+ * wait for activation to take place, this is simply fire-and-forget.
+ *
+ * pp_im must be a pointer to an immediate event talloced on
+ * a context owned by the calling thread, or the NULL context.
+ * Ownership of *pp_im will be transfered to the tevent library.
+ *
+ * pp_private can be null, or contents of *pp_private must be
+ * talloc'ed memory on a context owned by the calling thread
+ * or the NULL context. If non-null, ownership of *pp_private will
+ * be transfered to the tevent library.
+ *
+ * If you want to return a message, have the destination use the
+ * same function call to send back to the caller.
+ */
+
+
+void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
+				  struct tevent_immediate **pp_im,
+				  tevent_immediate_handler_t handler,
+				  void *pp_private_data)
+{
+	struct tevent_immediate_list *im_entry;
+	int ret;
+	char c;
+
+	ret = pthread_mutex_lock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+		return;
+	}
+
+	if (tp->write_fd == -1) {
+		/* In the process of being destroyed. Ignore. */
+		goto end;
+	}
+
+	/* Create a new immediate_list entry. MUST BE ON THE NULL CONTEXT */
+	im_entry = talloc_zero(NULL, struct tevent_immediate_list);
+	if (im_entry == NULL) {
+		goto end;
+	}
+
+	im_entry->handler = handler;
+	im_entry->im = talloc_move(im_entry, pp_im);
+
+	if (pp_private_data != NULL) {
+		void **pptr = (void **)pp_private_data;
+		im_entry->private_ptr = talloc_move(im_entry, pptr);
+	}
+
+	DLIST_ADD(tp->im_list, im_entry);
+
+	/* And notify the dest_ev_ctx to wake up. */
+	c = '\0';
+	(void)write(tp->write_fd, &c, 1);
+
+  end:
+
+	ret = pthread_mutex_unlock(&tp->mutex);
+	if (ret != 0) {
+		abort();
+		/* Notreached. */
+	}
+}
+#else
+/* !HAVE_PTHREAD */
+struct tevent_thread_proxy *tevent_thread_proxy_create(
+		struct tevent_context *dest_ev_ctx)
+{
+	errno = ENOSYS;
+	return NULL;
+}
+
+void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
+				  struct tevent_immediate **pp_im,
+				  tevent_immediate_handler_t handler,
+				  void *pp_private_data)
+{
+	;
+}
+#endif
diff -Nru tevent-0.9.25/tevent_util.h tevent-0.9.28/tevent_util.h
--- tevent-0.9.25/tevent_util.h	2014-09-16 18:04:31.000000000 +0000
+++ tevent-0.9.28/tevent_util.h	2016-02-26 03:24:44.000000000 +0000
@@ -53,10 +53,6 @@
   This allows us to find the tail of the list by using
   list_head->prev, which means we can add to the end of the list in
   O(1) time
-
-
-  Note that the 'type' arguments below are no longer needed, but
-  are kept for now to prevent an incompatible argument change
  */
 
 
@@ -131,9 +127,8 @@
 
 /*
    add to the end of a list.
-   Note that 'type' is ignored
 */
-#define DLIST_ADD_END(list, p, type)			\
+#define DLIST_ADD_END(list, p) \
 do { \
 	if (!(list)) { \
 		DLIST_ADD(list, p); \
@@ -151,20 +146,18 @@
 
 /*
    demote an element to the end of a list.
-   Note that 'type' is ignored
 */
-#define DLIST_DEMOTE(list, p, type)			\
+#define DLIST_DEMOTE(list, p) \
 do { \
 	DLIST_REMOVE(list, p); \
-	DLIST_ADD_END(list, p, NULL);		\
+	DLIST_ADD_END(list, p); \
 } while (0)
 
 /*
    concatenate two lists - putting all elements of the 2nd list at the
    end of the first list.
-   Note that 'type' is ignored
 */
-#define DLIST_CONCATENATE(list1, list2, type)	\
+#define DLIST_CONCATENATE(list1, list2) \
 do { \
 	if (!(list1)) { \
 		(list1) = (list2); \
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/3rdparty/gccdeps.py tevent-0.9.28/third_party/waf/wafadmin/3rdparty/gccdeps.py
--- tevent-0.9.25/third_party/waf/wafadmin/3rdparty/gccdeps.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/3rdparty/gccdeps.py	2016-02-26 03:24:44.000000000 +0000
@@ -15,7 +15,7 @@
 
 preprocessor_flag = '-MD'
 
-@feature('cc')
+@feature('cc', 'c')
 @before('apply_core')
 def add_mmd_cc(self):
 	if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/3rdparty/print_commands.py tevent-0.9.28/third_party/waf/wafadmin/3rdparty/print_commands.py
--- tevent-0.9.25/third_party/waf/wafadmin/3rdparty/print_commands.py	1970-01-01 00:00:00.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/3rdparty/print_commands.py	2016-02-26 03:24:44.000000000 +0000
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+
+"""
+In this case, print the commands being executed as strings
+(the commands are usually lists, so this can be misleading)
+"""
+
+import Build, Utils, Logs
+
+def exec_command(self, cmd, **kw):
+	txt = cmd
+	if isinstance(cmd, list):
+		txt = ' '.join(cmd)
+	Logs.debug('runner: %s' % txt)
+	if self.log:
+		self.log.write('%s\n' % cmd)
+		kw['log'] = self.log
+	try:
+		if not kw.get('cwd', None):
+			kw['cwd'] = self.cwd
+	except AttributeError:
+		self.cwd = kw['cwd'] = self.bldnode.abspath()
+	return Utils.exec_command(cmd, **kw)
+Build.BuildContext.exec_command = exec_command
+
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Build.py tevent-0.9.28/third_party/waf/wafadmin/Build.py
--- tevent-0.9.25/third_party/waf/wafadmin/Build.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Build.py	2016-02-26 03:24:44.000000000 +0000
@@ -645,6 +645,10 @@
 						cache[v] = x
 		return cache.get(env.variant() + '_' + name, None)
 
+	def get_tgen_by_name(self, name):
+		"""waf 1.8 api"""
+		return self.name_to_obj(name, self.env)
+
 	def flush(self, all=1):
 		"""tell the task generators to create the tasks"""
 
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Node.py tevent-0.9.28/third_party/waf/wafadmin/Node.py
--- tevent-0.9.25/third_party/waf/wafadmin/Node.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Node.py	2016-02-26 03:24:44.000000000 +0000
@@ -689,6 +689,13 @@
 					child = self.ensure_dir_node_from_path(k)
 				child.update_build_dir(env)
 
+	def read(self, flags='r', encoding='ISO8859-1'):
+		"""backported from waf 1.8"""
+		return Utils.readf(self.abspath(), flags, encoding)
+
+	def write(self, data, flags='w', encoding='ISO8859-1'):
+		"""backported from waf 1.8"""
+		Utils.writef(self.abspath(self.bld.env), data, flags, encoding)
 
 class Nodu(Node):
 	pass
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/TaskGen.py tevent-0.9.28/third_party/waf/wafadmin/TaskGen.py
--- tevent-0.9.25/third_party/waf/wafadmin/TaskGen.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/TaskGen.py	2016-02-26 03:24:44.000000000 +0000
@@ -242,6 +242,9 @@
 	def name_to_obj(self, name):
 		return self.bld.name_to_obj(name, self.env)
 
+	def get_tgen_by_name(self, name):
+		return self.bld.get_tgen_by_name(name)
+
 	def find_sources_in_dirs(self, dirnames, excludes=[], exts=[]):
 		"""
 		The attributes "excludes" and "exts" must be lists to avoid the confusion
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Tools/cc.py tevent-0.9.28/third_party/waf/wafadmin/Tools/cc.py
--- tevent-0.9.25/third_party/waf/wafadmin/Tools/cc.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Tools/cc.py	2016-02-26 03:24:44.000000000 +0000
@@ -23,7 +23,7 @@
 class cc_taskgen(ccroot.ccroot_abstract):
 	pass
 
-@feature('cc')
+@feature('c', 'cc')
 @before('apply_type_vars')
 @after('default_cc')
 def init_cc(self):
@@ -33,7 +33,7 @@
 	if not self.env['CC_NAME']:
 		raise Utils.WafError("At least one compiler (gcc, ..) must be selected")
 
-@feature('cc')
+@feature('c', 'cc')
 @after('apply_incpaths')
 def apply_obj_vars_cc(self):
 	"""after apply_incpaths for INC_PATHS"""
@@ -51,7 +51,7 @@
 	for i in env['CPPPATH']:
 		app('_CCINCFLAGS', cpppath_st % i)
 
-@feature('cc')
+@feature('c', 'cc')
 @after('apply_lib_vars')
 def apply_defines_cc(self):
 	"""after uselib is set for CCDEFINES"""
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Tools/ccroot.py tevent-0.9.28/third_party/waf/wafadmin/Tools/ccroot.py
--- tevent-0.9.25/third_party/waf/wafadmin/Tools/ccroot.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Tools/ccroot.py	2016-02-26 03:24:44.000000000 +0000
@@ -190,7 +190,7 @@
 
 	return os.path.join(dir, pattern % name)
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @before('apply_core')
 def default_cc(self):
 	"""compiled_tasks attribute must be set before the '.c->.o' tasks can be created"""
@@ -253,7 +253,7 @@
 	if self.install_path:
 		self.bld.install_files(self.install_path, self.link_task.outputs[0], env=self.env, chmod=self.chmod)
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
 def apply_incpaths(self):
 	"""used by the scanner
@@ -297,7 +297,7 @@
 	if USE_TOP_LEVEL:
 		self.env.append_value('INC_PATHS', self.bld.srcnode)
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('init_cc', 'init_cxx')
 @before('apply_lib_vars')
 def apply_type_vars(self):
@@ -339,7 +339,7 @@
 
 	self.link_task = tsk
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('apply_link', 'init_cc', 'init_cxx', 'apply_core')
 def apply_lib_vars(self):
 	"""after apply_link because of 'link_task'
@@ -523,7 +523,7 @@
 'frameworkpath' : 'FRAMEWORKPATH'
 }
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @before('init_cxx', 'init_cc')
 @before('apply_lib_vars', 'apply_obj_vars', 'apply_incpaths', 'init_cc')
 def add_extra_flags(self):
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Tools/config_c.py tevent-0.9.28/third_party/waf/wafadmin/Tools/config_c.py
--- tevent-0.9.25/third_party/waf/wafadmin/Tools/config_c.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Tools/config_c.py	2016-02-26 03:24:44.000000000 +0000
@@ -82,6 +82,10 @@
 		# RPATH later, and hence can potentially lead to linking
 		# in too old versions of our internal libs.
 		#
+		elif x == '-Wl,-rpath' or x == '-Wl,-R':
+			app('RPATH_' + uselib, lst.pop(0).lstrip('-Wl,'))
+		elif x.startswith('-Wl,-R,'):
+			app('RPATH_' + uselib, x[7:])
 		elif x.startswith('-Wl,-R'):
 			app('RPATH_' + uselib, x[6:])
 		elif x.startswith('-Wl,-rpath,'):
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Tools/msvc.py tevent-0.9.28/third_party/waf/wafadmin/Tools/msvc.py
--- tevent-0.9.25/third_party/waf/wafadmin/Tools/msvc.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Tools/msvc.py	2016-02-26 03:24:44.000000000 +0000
@@ -638,7 +638,7 @@
 ##### conf above, build below
 
 @after('apply_link')
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 def apply_flags_msvc(self):
 	if self.env.CC_NAME != 'msvc' or not self.link_task:
 		return
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Tools/osx.py tevent-0.9.28/third_party/waf/wafadmin/Tools/osx.py
--- tevent-0.9.25/third_party/waf/wafadmin/Tools/osx.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Tools/osx.py	2016-02-26 03:24:44.000000000 +0000
@@ -38,7 +38,7 @@
 
 # see WAF issue 285
 # and also http://trac.macports.org/ticket/17059
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @before('apply_lib_vars')
 def set_macosx_deployment_target(self):
 	if self.env['MACOSX_DEPLOYMENT_TARGET']:
@@ -47,7 +47,7 @@
 		if sys.platform == 'darwin':
 			os.environ['MACOSX_DEPLOYMENT_TARGET'] = '.'.join(platform.mac_ver()[0].split('.')[:2])
 
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 @after('apply_lib_vars')
 def apply_framework(self):
 	for x in self.to_list(self.env['FRAMEWORKPATH']):
@@ -145,7 +145,7 @@
 		self.env.append_value('LINKFLAGS', path)
 
 @before('apply_link', 'apply_lib_vars')
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
 def apply_bundle(self):
 	"""use env['MACBUNDLE'] to force all shlibs into mac bundles
 	or use obj.mac_bundle = True for specific targets only"""
diff -Nru tevent-0.9.25/third_party/waf/wafadmin/Utils.py tevent-0.9.28/third_party/waf/wafadmin/Utils.py
--- tevent-0.9.25/third_party/waf/wafadmin/Utils.py	2015-04-29 09:20:16.000000000 +0000
+++ tevent-0.9.28/third_party/waf/wafadmin/Utils.py	2016-02-26 03:24:44.000000000 +0000
@@ -147,6 +147,38 @@
 		# portability fixes may be added elsewhere (although, md5 should be everywhere by now)
 		md5 = None
 
+def readf(fname, m='r', encoding='ISO8859-1'):
+	"""backported from waf 1.8"""
+	if sys.hexversion > 0x3000000 and not 'b' in m:
+		m += 'b'
+		f = open(fname, m)
+		try:
+			txt = f.read()
+		finally:
+			f.close()
+		if encoding:
+			txt = txt.decode(encoding)
+		else:
+			txt = txt.decode()
+	else:
+		f = open(fname, m)
+		try:
+			txt = f.read()
+		finally:
+			f.close()
+	return txt
+
+def writef(fname, data, m='w', encoding='ISO8859-1'):
+	"""backported from waf 1.8"""
+	if sys.hexversion > 0x3000000 and not 'b' in m:
+		data = data.encode(encoding)
+		m += 'b'
+	f = open(fname, m)
+	try:
+		f.write(data)
+	finally:
+		f.close()
+
 class ordered_dict(UserDict):
 	def __init__(self, dict = None):
 		self.allkeys = []
@@ -423,8 +455,7 @@
 			os.makedirs(path)
 		except OSError, e:
 			if not os.path.isdir(path):
-				raise Errors.WafError('Cannot create the folder %r' % path, ex=e)
-
+				raise WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
 
 def cmd_output(cmd, **kw):
 
@@ -557,15 +588,6 @@
 		for dt in tooldir:
 			sys.path.remove(dt)
 
-def readf(fname, m='r'):
-	"get the contents of a file, it is not used anywhere for the moment"
-	f = open(fname, m)
-	try:
-		txt = f.read()
-	finally:
-		f.close()
-	return txt
-
 def nada(*k, **kw):
 	"""A function that does nothing"""
 	pass
diff -Nru tevent-0.9.25/wscript tevent-0.9.28/wscript
--- tevent-0.9.25/wscript	2015-06-13 01:00:10.000000000 +0000
+++ tevent-0.9.28/wscript	2016-02-26 03:24:44.000000000 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'tevent'
-VERSION = '0.9.25'
+VERSION = '0.9.28'
 
 blddir = 'bin'
 
@@ -83,7 +83,7 @@
 
     SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
              tevent_queue.c tevent_req.c tevent_select.c
-             tevent_poll.c
+             tevent_poll.c tevent_threads.c
              tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
 
     if bld.CONFIG_SET('HAVE_EPOLL'):
@@ -107,7 +107,7 @@
                           abi_directory='ABI',
                           abi_match='tevent_* _tevent_*',
                           vnum=VERSION,
-                          public_headers='tevent.h',
+                          public_headers=('' if private_library else 'tevent.h'),
                           public_headers_install=not private_library,
                           pc_files='tevent.pc',
                           private_library=private_library)
@@ -133,6 +133,9 @@
     '''test tevent'''
     print("The tevent testsuite is part of smbtorture in samba4")
 
+    samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
+    samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
+
     pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
     sys.exit(pyret)
 

Reply to: