summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-08 09:13:28 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:12 -0500
commit7eb3fc533d7016bc0f20adbc805a0fd926c783b4 (patch)
tree1e815fa035ebea2355c25fd77ec51e88c3a8ecfd /source4
parent91cf3943d3a6f327f831377ea9b335002e10e055 (diff)
downloadsamba-7eb3fc533d7016bc0f20adbc805a0fd926c783b4.tar.gz
samba-7eb3fc533d7016bc0f20adbc805a0fd926c783b4.tar.bz2
samba-7eb3fc533d7016bc0f20adbc805a0fd926c783b4.zip
r12125: make the deferred connection termination the default,
so that I can remove all the other versions of it metze (This used to be commit 82de98b8e9f3030449225634935a71a3dd7e117c)
Diffstat (limited to 'source4')
-rw-r--r--source4/smbd/service_stream.c27
-rw-r--r--source4/smbd/service_stream.h9
2 files changed, 30 insertions, 6 deletions
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 6f78643dae..b3d5fefb99 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -55,7 +55,24 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
{
struct event_context *event_ctx = srv_conn->event.ctx;
const struct model_ops *model_ops = srv_conn->model_ops;
+
+ if (!reason) reason = "unknwon reason";
+
+ srv_conn->terminate = reason;
+
+ if (srv_conn->processing) {
+ /*
+ * if we're currently inside the stream_io_handler(),
+ * deferr the termination to the end of stream_io_hendler()
+ *
+ * and we don't want to read or write to the connection...
+ */
+ event_set_fd_flags(srv_conn->event.fde, 0);
+ return;
+ }
+
talloc_free(srv_conn->event.fde);
+ srv_conn->event.fde = NULL;
talloc_free(srv_conn);
model_ops->terminate(event_ctx, reason);
}
@@ -68,13 +85,17 @@ static void stream_io_handler(struct event_context *ev, struct fd_event *fde,
{
struct stream_connection *conn = talloc_get_type(private,
struct stream_connection);
+
+ conn->processing = True;
if (flags & EVENT_FD_WRITE) {
conn->ops->send_handler(conn, flags);
- return;
+ } else if (flags & EVENT_FD_READ) {
+ conn->ops->recv_handler(conn, flags);
}
+ conn->processing = False;
- if (flags & EVENT_FD_READ) {
- conn->ops->recv_handler(conn, flags);
+ if (conn->terminate) {
+ stream_terminate_connection(conn, conn->terminate);
}
}
diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h
index 3ae7107419..6f1a967237 100644
--- a/source4/smbd/service_stream.h
+++ b/source4/smbd/service_stream.h
@@ -23,10 +23,10 @@
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
- * with a comment and maybe update struct process_model_critical_sizes.
+ * with a comment and maybe update struct stream_connection_critical_sizes.
*/
-/* version 1 - initial version - metze */
-#define SERVER_SERVICE_VERSION 1
+/* version 0 - initial version - metze */
+#define SERVER_SERVICE_VERSION 0
/*
top level context for an established stream connection
@@ -44,6 +44,9 @@ struct stream_connection {
struct socket_context *socket;
struct messaging_context *msg_ctx;
+
+ BOOL processing;
+ const char *terminate;
};