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;
}
/*
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);
+ }
}
/*
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);
+ }
}
/*