summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-01 21:29:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:56 -0500
commit19a6878380eec4a66fb9f15f4d7a16d80c4ee84d (patch)
treefb59d0dc63d9f89e36aa58537c78acea4c003800
parent20a0206a102694a1eae7be73be6ae91ff7f6abce (diff)
downloadsamba-19a6878380eec4a66fb9f15f4d7a16d80c4ee84d.tar.gz
samba-19a6878380eec4a66fb9f15f4d7a16d80c4ee84d.tar.bz2
samba-19a6878380eec4a66fb9f15f4d7a16d80c4ee84d.zip
r22634: make the events system much less dependent on the samba4 build system
(This used to be commit b0c8c1cd21e3f91431504d70a4bc0d3c6dee6071)
-rw-r--r--source4/lib/events/config.mk8
-rw-r--r--source4/lib/events/events.c13
-rw-r--r--source4/lib/events/events_aio.c18
-rw-r--r--source4/lib/events/events_epoll.c18
-rw-r--r--source4/lib/events/events_internal.h2
-rw-r--r--source4/lib/events/events_select.c12
-rw-r--r--source4/lib/events/events_signal.c1
-rw-r--r--source4/lib/events/events_standard.c18
8 files changed, 69 insertions, 21 deletions
diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk
index 1268c6f518..2e0a8a6028 100644
--- a/source4/lib/events/config.mk
+++ b/source4/lib/events/config.mk
@@ -3,28 +3,28 @@
OBJ_FILES = events_aio.o
PRIVATE_DEPENDENCIES = LIBAIO_LINUX
SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = events_aio_init
+INIT_FUNCTION = s4_events_aio_init
##############################
##############################
[MODULE::EVENTS_EPOLL]
OBJ_FILES = events_epoll.o
SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = events_epoll_init
+INIT_FUNCTION = s4_events_epoll_init
##############################
##############################
[MODULE::EVENTS_SELECT]
OBJ_FILES = events_select.o
SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = events_select_init
+INIT_FUNCTION = s4_events_select_init
##############################
##############################
[MODULE::EVENTS_STANDARD]
OBJ_FILES = events_standard.o
SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = events_standard_init
+INIT_FUNCTION = s4_events_standard_init
##############################
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index e2d5b4c397..3a81b55bd9 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -58,7 +58,9 @@
#include "lib/events/events.h"
#include "lib/events/events_internal.h"
#include "lib/util/dlinklist.h"
+#if _SAMBA_BUILD_
#include "build.h"
+#endif
struct event_ops_list {
struct event_ops_list *next, *prev;
@@ -72,15 +74,15 @@ static struct event_ops_list *event_backends;
/*
register an events backend
*/
-NTSTATUS event_register_backend(const char *name, const struct event_ops *ops)
+bool event_register_backend(const char *name, const struct event_ops *ops)
{
struct event_ops_list *e;
e = talloc(talloc_autofree_context(), struct event_ops_list);
- NT_STATUS_HAVE_NO_MEMORY(e);
+ if (e == NULL) return False;
e->name = name;
e->ops = ops;
DLIST_ADD(event_backends, e);
- return NT_STATUS_OK;
+ return True;
}
/*
@@ -88,12 +90,17 @@ NTSTATUS event_register_backend(const char *name, const struct event_ops *ops)
*/
static void event_backend_init(void)
{
+#if _SAMBA_BUILD_
init_module_fn static_init[] = STATIC_LIBEVENTS_MODULES;
init_module_fn *shared_init;
if (event_backends) return;
shared_init = load_samba_modules(NULL, "LIBEVENTS");
run_init_functions(static_init);
run_init_functions(shared_init);
+#else
+ bool events_standard_init(void);
+ events_standard_init();
+#endif
}
/*
diff --git a/source4/lib/events/events_aio.c b/source4/lib/events/events_aio.c
index ddadedf6e3..9f4e9c5612 100644
--- a/source4/lib/events/events_aio.c
+++ b/source4/lib/events/events_aio.c
@@ -165,9 +165,9 @@ static void epoll_mod_event(struct aio_event_context *aio_ev, struct fd_event *f
static void epoll_change_event(struct aio_event_context *aio_ev, struct fd_event *fde)
{
- BOOL got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
- BOOL want_read = (fde->flags & EVENT_FD_READ);
- BOOL want_write= (fde->flags & EVENT_FD_WRITE);
+ bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
+ bool want_read = (fde->flags & EVENT_FD_READ);
+ bool want_write= (fde->flags & EVENT_FD_WRITE);
if (aio_ev->epoll_fd == -1) return;
@@ -512,7 +512,17 @@ static const struct event_ops aio_event_ops = {
.loop_wait = aio_event_loop_wait,
};
-NTSTATUS events_aio_init(void)
+bool events_aio_init(void)
{
return event_register_backend("aio", &aio_event_ops);
}
+
+#if _SAMBA_BUILD_
+NTSTATUS s4_events_aio_init(void)
+{
+ if (!events_aio_init()) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ return NT_STATUS_OK;
+}
+#endif
diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c
index 58eeb08cd5..41a6509e36 100644
--- a/source4/lib/events/events_epoll.c
+++ b/source4/lib/events/events_epoll.c
@@ -165,9 +165,9 @@ static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct fd_even
static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_event *fde)
{
- BOOL got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
- BOOL want_read = (fde->flags & EVENT_FD_READ);
- BOOL want_write= (fde->flags & EVENT_FD_WRITE);
+ bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
+ bool want_read = (fde->flags & EVENT_FD_READ);
+ bool want_write= (fde->flags & EVENT_FD_WRITE);
if (epoll_ev->epoll_fd == -1) return;
@@ -413,7 +413,17 @@ static const struct event_ops epoll_event_ops = {
.loop_wait = epoll_event_loop_wait,
};
-NTSTATUS events_epoll_init(void)
+bool events_epoll_init(void)
{
return event_register_backend("epoll", &epoll_event_ops);
}
+
+#if _SAMBA_BUILD_
+NTSTATUS s4_events_epoll_init(void)
+{
+ if (!events_epoll_init()) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ return NT_STATUS_OK;
+}
+#endif
diff --git a/source4/lib/events/events_internal.h b/source4/lib/events/events_internal.h
index 39fade2fdb..04b92df550 100644
--- a/source4/lib/events/events_internal.h
+++ b/source4/lib/events/events_internal.h
@@ -113,7 +113,7 @@ struct event_context {
};
-NTSTATUS event_register_backend(const char *name, const struct event_ops *ops);
+bool event_register_backend(const char *name, const struct event_ops *ops);
struct timed_event *common_event_add_timed(struct event_context *, TALLOC_CTX *,
struct timeval, event_timed_handler_t, void *);
diff --git a/source4/lib/events/events_select.c b/source4/lib/events/events_select.c
index 36b5afc42e..291ddbde2b 100644
--- a/source4/lib/events/events_select.c
+++ b/source4/lib/events/events_select.c
@@ -291,7 +291,17 @@ static const struct event_ops select_event_ops = {
.loop_wait = select_event_loop_wait,
};
-NTSTATUS events_select_init(void)
+bool events_select_init(void)
{
return event_register_backend("select", &select_event_ops);
}
+
+#if _SAMBA_BUILD_
+NTSTATUS s4_events_select_init(void)
+{
+ if (!events_select_init()) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ return NT_STATUS_OK;
+}
+#endif
diff --git a/source4/lib/events/events_signal.c b/source4/lib/events/events_signal.c
index 9a8ebea6ae..2a75a0c0bd 100644
--- a/source4/lib/events/events_signal.c
+++ b/source4/lib/events/events_signal.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "system/select.h"
+#include "system/wait.h"
#include "lib/util/dlinklist.h"
#include "lib/events/events.h"
#include "lib/events/events_internal.h"
diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c
index 3b26b1073d..8495ccdec0 100644
--- a/source4/lib/events/events_standard.c
+++ b/source4/lib/events/events_standard.c
@@ -180,9 +180,9 @@ static void epoll_mod_event(struct std_event_context *std_ev, struct fd_event *f
static void epoll_change_event(struct std_event_context *std_ev, struct fd_event *fde)
{
- BOOL got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
- BOOL want_read = (fde->flags & EVENT_FD_READ);
- BOOL want_write= (fde->flags & EVENT_FD_WRITE);
+ bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
+ bool want_read = (fde->flags & EVENT_FD_READ);
+ bool want_write= (fde->flags & EVENT_FD_WRITE);
if (std_ev->epoll_fd == -1) return;
@@ -549,7 +549,17 @@ static const struct event_ops std_event_ops = {
};
-NTSTATUS events_standard_init(void)
+bool events_standard_init(void)
{
return event_register_backend("standard", &std_event_ops);
}
+
+#if _SAMBA_BUILD_
+NTSTATUS s4_events_standard_init(void)
+{
+ if (!events_standard_init()) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ return NT_STATUS_OK;
+}
+#endif