The branch, master has been updated via 61f34e2 s3:pylibsmb: make sure we get tevent debug messages via 64d98c5 s3:lib/events: make use of samba_tevent_set_debug() via 1b75475 s4:lib/events: make use of samba_tevent_set_debug() via 6b948cf lib/util: add samba_tevent_set_debug() via 6205262 lib/util: allow samba_tevent_debug() to take a name as context via bf0dcc9 auth/pycredentials: make use of samba_tevent_context_init() via 8ec4d9c s4:pyregistry: make use of samba_tevent_context_init() via 5aee3a4 s4:pygensec: make use of samba_tevent_context_init() via 2fb69f5 s3:lib/events: add missing TEVENT_TRACE_BEFORE/AFTER_WAIT handling from f14ba64 s4:winbindd: fix spacing and line length in cmd_getpwnam_recv_domain()
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 61f34e2d25058452ab16f9d7ec5fc2776ab135eb Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:29:18 2013 +0100 s3:pylibsmb: make sure we get tevent debug messages Pair-Programmed-With: Michael Adam <ob...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Signed-off-by: Michael Adam <ob...@samba.org> Autobuild-User(master): Michael Adam <ob...@samba.org> Autobuild-Date(master): Thu Feb 28 14:34:24 CET 2013 on sn-devel-104 commit 64d98c532357c71f27bd84539b3f7a14fd0f952b Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:39:05 2013 +0100 s3:lib/events: make use of samba_tevent_set_debug() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 1b75475ade962f7a61db0fc1aacca9d9daa48861 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:35:50 2013 +0100 s4:lib/events: make use of samba_tevent_set_debug() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 6b948cf54b75ac44c4857e8da8f7db251e00b67b Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 09:00:56 2013 +0100 lib/util: add samba_tevent_set_debug() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 6205262d38a4f7c5f97f1cb4025914ee18abd74d Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:23:42 2013 +0100 lib/util: allow samba_tevent_debug() to take a name as context Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit bf0dcc918dc63939fb3d0b9ce9339b432b98cb74 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:32:35 2013 +0100 auth/pycredentials: make use of samba_tevent_context_init() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 8ec4d9cb00b818045f040b0a3f60946543d35f75 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:31:41 2013 +0100 s4:pyregistry: make use of samba_tevent_context_init() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 5aee3a45e4c398473ba6e8e61ed34df839674a40 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 21 08:30:51 2013 +0100 s4:pygensec: make use of samba_tevent_context_init() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 2fb69f51c47c8859485011879afb11650835ecbe Author: Stefan Metzmacher <me...@samba.org> Date: Thu Feb 28 10:54:21 2013 +0100 s3:lib/events: add missing TEVENT_TRACE_BEFORE/AFTER_WAIT handling Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> ----------------------------------------------------------------------- Summary of changes: auth/credentials/pycredentials.c | 2 +- lib/util/samba_util.h | 8 +++++++ lib/util/tevent_debug.c | 28 +++++++++++++++++++----- source3/lib/events.c | 43 ++++++------------------------------- source3/libsmb/pylibsmb.c | 9 +++++++- source4/auth/gensec/pygensec.c | 2 +- source4/lib/events/tevent_s4.c | 36 +------------------------------ source4/lib/registry/pyregistry.c | 2 +- 8 files changed, 49 insertions(+), 81 deletions(-) Changeset truncated at 500 lines: diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index 5d21721..14fd5e0 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -341,7 +341,7 @@ static PyObject *py_creds_get_named_ccache(pytalloc_Object *self, PyObject *args return NULL; } - event_ctx = tevent_context_init(mem_ctx); + event_ctx = samba_tevent_context_init(mem_ctx); ret = cli_credentials_get_named_ccache(creds, event_ctx, lp_ctx, ccache_name, &ccc, &error_string); diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index f59dc70..6a4373e 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -966,4 +966,12 @@ bool server_id_is_disconnected(const struct server_id *id); */ struct tevent_context *samba_tevent_context_init(TALLOC_CTX *mem_ctx); +/* + * if same samba code needs to use a specific tevent backend + * it can use something like this: + * + * samba_tevent_set_debug(ev, "pysmb_tevent"); + */ +void samba_tevent_set_debug(struct tevent_context *ev, const char *name); + #endif /* _SAMBA_UTIL_H_ */ diff --git a/lib/util/tevent_debug.c b/lib/util/tevent_debug.c index 3a5a313..3f8c649 100644 --- a/lib/util/tevent_debug.c +++ b/lib/util/tevent_debug.c @@ -30,7 +30,7 @@ static void samba_tevent_debug(void *context, va_list ap) { int samba_level = -1; - char *s = NULL; + switch (level) { case TEVENT_DEBUG_FATAL: samba_level = 0; @@ -47,20 +47,36 @@ static void samba_tevent_debug(void *context, }; if (CHECK_DEBUGLVL(samba_level)) { - vasprintf(&s, fmt, ap); - if (!s) return; - DEBUG(samba_level, ("samba_tevent: %s", s)); - free(s); + const char *name = (const char *)context; + char *message = NULL; + int ret; + + ret = vasprintf(&message, fmt, ap); + if (ret == -1) { + return; + } + + if (name == NULL) { + name = "samba_tevent"; + } + + DEBUG(samba_level, ("%s: %s", name, message)); + free(message); } } +void samba_tevent_set_debug(struct tevent_context *ev, const char *name) +{ + tevent_set_debug(ev, samba_tevent_debug, name); +} + struct tevent_context *samba_tevent_context_init(TALLOC_CTX *mem_ctx) { struct tevent_context *ev; ev = tevent_context_init(mem_ctx); if (ev) { - tevent_set_debug(ev, samba_tevent_debug, NULL); + samba_tevent_set_debug(ev, NULL); } return ev; diff --git a/source3/lib/events.c b/source3/lib/events.c index 011fcdc..0a8039a 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -314,6 +314,7 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location) int timeout; int num_pfds; int ret; + int poll_errno; timeout = INT_MAX; @@ -333,7 +334,12 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location) return -1; } + tevent_trace_point_callback(ev, TEVENT_TRACE_BEFORE_WAIT); ret = poll(state->pfds, num_pfds, timeout); + poll_errno = errno; + tevent_trace_point_callback(ev, TEVENT_TRACE_AFTER_WAIT); + errno = poll_errno; + if (ret == -1 && errno != EINTR) { tevent_debug(ev, TEVENT_DEBUG_FATAL, "poll() failed: %d:%s\n", @@ -408,41 +414,6 @@ static bool s3_tevent_init(void) return initialized; } -/* - this is used to catch debug messages from events -*/ -static void s3_event_debug(void *context, enum tevent_debug_level level, - const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); - -static void s3_event_debug(void *context, enum tevent_debug_level level, - const char *fmt, va_list ap) -{ - int samba_level = -1; - char *s = NULL; - switch (level) { - case TEVENT_DEBUG_FATAL: - samba_level = 0; - break; - case TEVENT_DEBUG_ERROR: - samba_level = 1; - break; - case TEVENT_DEBUG_WARNING: - samba_level = 2; - break; - case TEVENT_DEBUG_TRACE: - samba_level = 11; - break; - - }; - if (CHECK_DEBUGLVL(samba_level)) { - if (vasprintf(&s, fmt, ap) == -1) { - return; - } - DEBUG(samba_level, ("s3_event: %s", s)); - free(s); - } -} - struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx) { struct tevent_context *ev; @@ -451,7 +422,7 @@ struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx) ev = tevent_context_init_byname(mem_ctx, "s3"); if (ev) { - tevent_set_debug(ev, s3_event_debug, NULL); + samba_tevent_set_debug(ev, "s3_tevent"); } return ev; diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 900d052..4fd5921 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -201,6 +201,7 @@ static bool py_cli_state_setup_ev(struct py_cli_state *self) if (self->ev == NULL) { goto fail; } + samba_tevent_set_debug(self->ev, "pylibsmb_tevent_mt"); tevent_set_trace_callback(self->ev, py_cli_state_trace_callback, self); self->thread_state = talloc_zero(NULL, struct py_cli_thread); @@ -336,7 +337,13 @@ static void py_tevent_signalme(struct tevent_req *req) static bool py_cli_state_setup_ev(struct py_cli_state *self) { self->ev = tevent_context_init(NULL); - return (self->ev != NULL); + if (self->ev == NULL) { + return false; + } + + samba_tevent_set_debug(self->ev, "pylibsmb_tevent"); + + return true; } static int py_tevent_req_wait(struct tevent_context *ev, diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index a991aef..a84fbf8 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -415,7 +415,7 @@ static PyObject *py_gensec_update(PyObject *self, PyObject *args) in.data = (uint8_t *)PyString_AsString(py_in); in.length = PyString_Size(py_in); - ev = tevent_context_init(mem_ctx); + ev = samba_tevent_context_init(mem_ctx); if (ev == NULL) { PyErr_NoMemory(); PyObject_Del(self); diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c index 6770dd0..f80424f 100644 --- a/source4/lib/events/tevent_s4.c +++ b/source4/lib/events/tevent_s4.c @@ -21,40 +21,6 @@ #include "lib/events/events.h" /* - this is used to catch debug messages from events -*/ -static void ev_wrap_debug(void *context, enum tevent_debug_level level, - const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); - -static void ev_wrap_debug(void *context, enum tevent_debug_level level, - const char *fmt, va_list ap) -{ - int samba_level = -1; - char *s = NULL; - switch (level) { - case TEVENT_DEBUG_FATAL: - samba_level = 0; - break; - case TEVENT_DEBUG_ERROR: - samba_level = 1; - break; - case TEVENT_DEBUG_WARNING: - samba_level = 2; - break; - case TEVENT_DEBUG_TRACE: - samba_level = 50; - break; - - }; - if (CHECK_DEBUGLVL(samba_level)) { - vasprintf(&s, fmt, ap); - if (!s) return; - DEBUG(samba_level, ("tevent: %s", s)); - free(s); - } -} - -/* create a event_context structure. This must be the first events call, and all subsequent calls pass this event_context as the first element. Event handlers also receive this as their first argument. @@ -67,7 +33,7 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx) ev = tevent_context_init_byname(mem_ctx, NULL); if (ev) { - tevent_set_debug(ev, ev_wrap_debug, NULL); + samba_tevent_set_debug(ev, "s4_tevent"); tevent_loop_allow_nesting(ev); } return ev; diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index ad411e8..8f96710 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -288,7 +288,7 @@ static PyObject *py_open_hive(PyTypeObject *type, PyObject *args, PyObject *kwar session_info = NULL; result = reg_open_hive(NULL, location, session_info, credentials, - tevent_context_init(NULL), + samba_tevent_context_init(NULL), lp_ctx, &hive_key); talloc_free(mem_ctx); PyErr_WERROR_NOT_OK_RAISE(result); -- Samba Shared Repository