summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-01-03 15:24:31 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-03 19:58:57 +0100
commit47d532fa685d46752650225c807f579ce658b323 (patch)
treeb34813da369a6402fb41c8a7f9a21a565afb20a4
parent1c8580cfa937bef1b15842b5b0615d7926b12402 (diff)
downloadsamba-47d532fa685d46752650225c807f579ce658b323.tar.gz
samba-47d532fa685d46752650225c807f579ce658b323.tar.bz2
samba-47d532fa685d46752650225c807f579ce658b323.zip
s4:smbd: convert to tevent_* api
metze
-rw-r--r--source4/smbd/config.mk3
-rw-r--r--source4/smbd/server.c18
-rw-r--r--source4/smbd/service_named_pipe.c6
-rw-r--r--source4/smbd/service_stream.c30
-rw-r--r--source4/smbd/service_task.c1
5 files changed, 34 insertions, 24 deletions
diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk
index e0b09f4b8c..a76d10cbe7 100644
--- a/source4/smbd/config.mk
+++ b/source4/smbd/config.mk
@@ -2,7 +2,7 @@
[SUBSYSTEM::service]
PRIVATE_DEPENDENCIES = \
- LIBEVENTS MESSAGING samba_socket NDR_NAMED_PIPE_AUTH
+ LIBTEVENT MESSAGING samba_socket NDR_NAMED_PIPE_AUTH
service_OBJ_FILES = $(addprefix $(smbdsrcdir)/, \
service.o \
@@ -21,6 +21,7 @@ $(eval $(call proto_header_template,$(smbdsrcdir)/pidfile.h,$(PIDFILE_OBJ_FILES:
[BINARY::samba]
INSTALLDIR = SBINDIR
PRIVATE_DEPENDENCIES = \
+ LIBEVENTS \
process_model \
service \
LIBSAMBA-HOSTCONFIG \
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 1eb3e42501..df970661f1 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -323,7 +323,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
if (opt_interactive) {
/* terminate when stdin goes away */
- stdin_event_flags = EVENT_FD_READ;
+ stdin_event_flags = TEVENT_FD_READ;
} else {
/* stay alive forever */
stdin_event_flags = 0;
@@ -333,15 +333,15 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
#ifdef SIGTTIN
signal(SIGTTIN, SIG_IGN);
#endif
- event_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
- server_stdin_handler,
- discard_const(binary_name));
+ tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
+ server_stdin_handler,
+ discard_const(binary_name));
if (max_runtime) {
- event_add_timed(event_ctx, event_ctx,
- timeval_current_ofs(max_runtime, 0),
- max_runtime_handler,
- discard_const(binary_name));
+ tevent_add_timer(event_ctx, event_ctx,
+ timeval_current_ofs(max_runtime, 0),
+ max_runtime_handler,
+ discard_const(binary_name));
}
DEBUG(0,("%s: using '%s' process model\n", binary_name, model));
@@ -354,7 +354,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
/* wait for events - this is where smbd sits for most of its
life */
- event_loop_wait(event_ctx);
+ tevent_loop_wait(event_ctx);
/* as everything hangs off this event context, freeing it
should initiate a clean shutdown of all services */
diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c
index 94fd501ffe..02b71de7c3 100644
--- a/source4/smbd/service_named_pipe.c
+++ b/source4/smbd/service_named_pipe.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "lib/events/events.h"
+#include <tevent.h>
#include "lib/socket/socket.h"
#include "smbd/service.h"
#include "param/param.h"
@@ -49,7 +49,7 @@ static void named_pipe_handover_connection(void *private_data)
private_data, struct named_pipe_connection);
struct stream_connection *conn = pipe_conn->connection;
- EVENT_FD_NOT_WRITEABLE(conn->event.fde);
+ TEVENT_FD_NOT_WRITEABLE(conn->event.fde);
if (!NT_STATUS_IS_OK(pipe_conn->status)) {
stream_terminate_connection(conn, nt_errstr(pipe_conn->status));
@@ -64,7 +64,7 @@ static void named_pipe_handover_connection(void *private_data)
talloc_free(pipe_conn);
/* we're now ready to start receiving events on this stream */
- EVENT_FD_READABLE(conn->event.fde);
+ TEVENT_FD_READABLE(conn->event.fde);
/*
* hand over to the real pipe implementation,
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index a5642c258f..6dff01f4f3 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -21,8 +21,8 @@
*/
#include "includes.h"
+#include <tevent.h>
#include "process_model.h"
-#include "lib/events/events.h"
#include "lib/socket/socket.h"
#include "smbd/service.h"
#include "smbd/service_stream.h"
@@ -72,7 +72,7 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
*
* and we don't want to read or write to the connection...
*/
- event_set_fd_flags(srv_conn->event.fde, 0);
+ tevent_fd_set_flags(srv_conn->event.fde, 0);
return;
}
@@ -88,9 +88,9 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
static void stream_io_handler(struct stream_connection *conn, uint16_t flags)
{
conn->processing++;
- if (flags & EVENT_FD_WRITE) {
+ if (flags & TEVENT_FD_WRITE) {
conn->ops->send_handler(conn, flags);
- } else if (flags & EVENT_FD_READ) {
+ } else if (flags & TEVENT_FD_READ) {
conn->ops->recv_handler(conn, flags);
}
conn->processing--;
@@ -144,9 +144,14 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev,
srv_conn->msg_ctx = msg_ctx;
srv_conn->event.ctx = ev;
srv_conn->lp_ctx = lp_ctx;
- srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
- EVENT_FD_READ,
- stream_io_handler_fde, srv_conn);
+ srv_conn->event.fde = tevent_add_fd(ev, srv_conn, socket_get_fd(sock),
+ TEVENT_FD_READ,
+ stream_io_handler_fde, srv_conn);
+ if (!srv_conn->event.fde) {
+ talloc_free(srv_conn);
+ return NT_STATUS_NO_MEMORY;
+ }
+
*_srv_conn = srv_conn;
return NT_STATUS_OK;
}
@@ -179,14 +184,19 @@ static void stream_new_connection(struct tevent_context *ev,
srv_conn->ops = stream_socket->ops;
srv_conn->event.ctx = ev;
srv_conn->lp_ctx = lp_ctx;
- srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
- 0, stream_io_handler_fde, srv_conn);
if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL, lp_default_service(lp_ctx)), lp_hostsdeny(NULL, lp_default_service(lp_ctx)))) {
stream_terminate_connection(srv_conn, "denied by access rules");
return;
}
+ srv_conn->event.fde = tevent_add_fd(ev, srv_conn, socket_get_fd(sock),
+ 0, stream_io_handler_fde, srv_conn);
+ if (!srv_conn->event.fde) {
+ stream_terminate_connection(srv_conn, "tevent_add_fd() failed");
+ return;
+ }
+
/* setup to receive internal messages on this connection */
srv_conn->msg_ctx = messaging_init(srv_conn,
lp_messaging_path(srv_conn, lp_ctx),
@@ -214,7 +224,7 @@ static void stream_new_connection(struct tevent_context *ev,
talloc_free(s);
/* we're now ready to start receiving events on this stream */
- EVENT_FD_READABLE(srv_conn->event.fde);
+ TEVENT_FD_READABLE(srv_conn->event.fde);
/* call the server specific accept code */
stream_socket->ops->accept_connection(srv_conn);
diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c
index 34ce755b93..d3951a4a9a 100644
--- a/source4/smbd/service_task.c
+++ b/source4/smbd/service_task.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "process_model.h"
-#include "lib/events/events.h"
#include "smbd/service.h"
#include "smbd/service_task.h"
#include "lib/messaging/irpc.h"