summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/events/config.mk2
-rw-r--r--source4/lib/events/events.h2
-rw-r--r--source4/lib/events/events_internal.h5
-rw-r--r--source4/lib/events/tevent_s4.c38
-rw-r--r--source4/lib/registry/pyregistry.c2
-rw-r--r--source4/lib/registry/regf.c4
-rw-r--r--source4/lib/registry/tools/common.c2
-rw-r--r--source4/lib/registry/tools/regtree.c13
-rw-r--r--source4/lib/socket/socket.c9
-rw-r--r--source4/lib/socket/socket.h6
10 files changed, 56 insertions, 27 deletions
diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk
index a1b2cd218a..c07a21bc75 100644
--- a/source4/lib/events/config.mk
+++ b/source4/lib/events/config.mk
@@ -4,4 +4,4 @@ CFLAGS = -Ilib/events
LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, tevent_s4.o)
-PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h)
+PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h)
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h
index 698ff2919b..1b2dbde32b 100644
--- a/source4/lib/events/events.h
+++ b/source4/lib/events/events.h
@@ -3,5 +3,5 @@
#define TEVENT_COMPAT_DEFINES 1
#include <../lib/tevent/tevent.h>
struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx);
-struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx);
+struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx) _DEPRECATED_;
#endif /* __LIB_EVENTS_H__ */
diff --git a/source4/lib/events/events_internal.h b/source4/lib/events/events_internal.h
deleted file mode 100644
index 055bfe1a92..0000000000
--- a/source4/lib/events/events_internal.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef __LIB_EVENTS_INTERNAL_H__
-#define __LIB_EVENTS_INTERNAL_H__
-#define TEVENT_COMPAT_DEFINES 1
-#include <../lib/tevent/tevent_internal.h>
-#endif /* __LIB_EVENTS_INTERNAL_H__ */
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c
index b3de7e667a..34a34a8e0b 100644
--- a/source4/lib/events/tevent_s4.c
+++ b/source4/lib/events/tevent_s4.c
@@ -17,38 +17,37 @@
*/
#include "includes.h"
-#include <events.h>
-#include <events_internal.h>
+#include "lib/events/events.h"
/*
this is used to catch debug messages from events
*/
-static void ev_wrap_debug(void *context, enum ev_debug_level level,
+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 ev_debug_level level,
+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 EV_DEBUG_FATAL:
+ case TEVENT_DEBUG_FATAL:
samba_level = 0;
break;
- case EV_DEBUG_ERROR:
+ case TEVENT_DEBUG_ERROR:
samba_level = 1;
break;
- case EV_DEBUG_WARNING:
+ case TEVENT_DEBUG_WARNING:
samba_level = 2;
break;
- case EV_DEBUG_TRACE:
+ case TEVENT_DEBUG_TRACE:
samba_level = 5;
break;
};
vasprintf(&s, fmt, ap);
if (!s) return;
- DEBUG(samba_level, ("events: %s\n", s));
+ DEBUG(samba_level, ("tevent: %s\n", s));
free(s);
}
@@ -63,10 +62,27 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx)
{
struct tevent_context *ev;
- ev = event_context_init_byname(mem_ctx, NULL);
+ ev = tevent_context_init_byname(mem_ctx, NULL);
if (ev) {
- ev_set_debug(ev, ev_wrap_debug, NULL);
+ tevent_set_debug(ev, ev_wrap_debug, NULL);
}
return ev;
}
+/*
+ find an event context that is a parent of the given memory context,
+ or create a new event context as a child of the given context if
+ none is found
+
+ This should be used in preference to event_context_init() in places
+ where you would prefer to use the existing event context if possible
+ (which is most situations)
+*/
+struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx)
+{
+ struct tevent_context *ev = talloc_find_parent_bytype(mem_ctx, struct tevent_context);
+ if (ev == NULL) {
+ ev = tevent_context_init(mem_ctx);
+ }
+ return ev;
+}
diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c
index 2d2f2fb685..357305c4de 100644
--- a/source4/lib/registry/pyregistry.c
+++ b/source4/lib/registry/pyregistry.c
@@ -357,7 +357,7 @@ static PyObject *py_open_ldb_file(PyObject *self, PyObject *args, PyObject *kwar
session_info = NULL; /* FIXME */
result = reg_open_ldb_file(NULL, location, session_info, credentials,
- event_context_init(NULL), lp_ctx, &key);
+ tevent_context_init(NULL), lp_ctx, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
return py_talloc_import(&PyHiveKey, key);
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index a869ed4440..4cbcb09a10 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -543,7 +543,7 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key,
if (vk->data_length & 0x80000000) {
vk->data_length &=~0x80000000;
- data->data = (uint8_t *)&vk->data_offset;
+ data->data = talloc_memdup(ctx, (uint8_t *)&vk->data_offset, vk->data_length);
data->length = vk->data_length;
} else {
*data = hbin_get(regf, vk->data_offset);
@@ -2045,7 +2045,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
struct tdr_pull *pull;
int i;
- regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
+ regf = (struct regf_data *)talloc_zero(parent_ctx, struct regf_data);
regf->iconv_convenience = iconv_convenience;
diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c
index c9f1248bf8..d997cb0fde 100644
--- a/source4/lib/registry/tools/common.c
+++ b/source4/lib/registry/tools/common.c
@@ -51,7 +51,7 @@ struct registry_key *reg_common_open_file(const char *path,
struct registry_context *h = NULL;
WERROR error;
- error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
+ error = reg_open_hive(ev_ctx, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s': %s \n",
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index cca009a0e2..948ed49312 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -55,13 +55,16 @@ static void print_tree(int level, struct registry_key *p,
&keyname,
NULL,
NULL)); i++) {
- SMB_ASSERT(strlen(keyname) > 0);
+
+ SMB_ASSERT(strlen(keyname) > 0);
if (!W_ERROR_IS_OK(reg_open_key(mem_ctx, p, keyname, &subkey)))
- continue;
+ continue;
+
print_tree(level+1, subkey, (fullpath && strlen(name))?
- talloc_asprintf(mem_ctx, "%s\\%s",
- name, keyname):
- keyname, fullpath, novals);
+ talloc_asprintf(mem_ctx, "%s\\%s",
+ name, keyname):
+ keyname, fullpath, novals);
+ talloc_free(subkey);
}
talloc_free(mem_ctx);
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index 26cdac99a3..9d30e0a77e 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -37,6 +37,15 @@ static int socket_destructor(struct socket_context *sock)
return 0;
}
+_PUBLIC_ void socket_tevent_fd_close_fn(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ int fd,
+ void *private_data)
+{
+ /* this might be the socket_wrapper swrap_close() */
+ close(fd);
+}
+
_PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socket_ops *ops,
struct socket_context **new_sock,
enum socket_type type, uint32_t flags)
diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h
index 7a27e3070b..e9338127c4 100644
--- a/source4/lib/socket/socket.h
+++ b/source4/lib/socket/socket.h
@@ -21,6 +21,7 @@
#define _SAMBA_SOCKET_H
struct tevent_context;
+struct tevent_fd;
struct socket_context;
enum socket_type {
@@ -205,6 +206,11 @@ NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx, const char *server_address,
void set_socket_options(int fd, const char *options);
void socket_set_flags(struct socket_context *socket, unsigned flags);
+void socket_tevent_fd_close_fn(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ int fd,
+ void *private_data);
+
extern bool testnonblock;
#endif /* _SAMBA_SOCKET_H */