summaryrefslogtreecommitdiff
path: root/source4/ldap_server
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ldap_server')
-rw-r--r--source4/ldap_server/ldap_server.c27
-rw-r--r--source4/ldap_server/ldap_server.h3
2 files changed, 25 insertions, 5 deletions
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 71a7172e5c..83ce059756 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -40,11 +40,12 @@
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn,
const char *reason)
{
- if (conn->tls) {
- talloc_free(conn->tls);
- conn->tls = NULL;
- }
- stream_terminate_connection(conn->connection, reason);
+ /* we don't actually do the stream termination here as the
+ recv/send functions dereference the connection after the
+ packet processing callbacks. Instead we mark it for
+ termination and do the real termination in the send/recv
+ functions */
+ conn->terminate = reason;
}
/*
@@ -299,6 +300,14 @@ static void ldapsrv_recv(struct stream_connection *c, uint16_t flags)
conn->processing = False;
EVENT_FD_READABLE(c->event.fde);
+
+ if (conn->terminate) {
+ if (conn->tls) {
+ talloc_free(conn->tls);
+ conn->tls = NULL;
+ }
+ stream_terminate_connection(conn->connection, conn->terminate);
+ }
}
/*
@@ -331,6 +340,14 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
if (conn->send_queue == NULL) {
EVENT_FD_NOT_WRITEABLE(c->event.fde);
}
+
+ if (conn->terminate) {
+ if (conn->tls) {
+ talloc_free(conn->tls);
+ conn->tls = NULL;
+ }
+ stream_terminate_connection(conn->connection, conn->terminate);
+ }
}
/*
diff --git a/source4/ldap_server/ldap_server.h b/source4/ldap_server/ldap_server.h
index a1981843a6..2aa6530f9f 100644
--- a/source4/ldap_server/ldap_server.h
+++ b/source4/ldap_server/ldap_server.h
@@ -38,6 +38,9 @@ struct ldapsrv_connection {
struct data_blob_list_item *send_queue;
BOOL processing;
+
+ /* connection should be terminated if non-null */
+ const char *terminate;
};
struct ldapsrv_call {