summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-08 10:23:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:12 -0500
commite246a067515b1fdb725ca1f8e7b406cc84a89e81 (patch)
treeb12f8b4cf4a681bef53ed90be035022d949b1906
parent7eb3fc533d7016bc0f20adbc805a0fd926c783b4 (diff)
downloadsamba-e246a067515b1fdb725ca1f8e7b406cc84a89e81.tar.gz
samba-e246a067515b1fdb725ca1f8e7b406cc84a89e81.tar.bz2
samba-e246a067515b1fdb725ca1f8e7b406cc84a89e81.zip
r12126: get rid of the local ->terminate hacks, we do that genericly now
metze (This used to be commit a7baf165c10c00096265b790d5362905c527806a)
-rw-r--r--source4/ldap_server/ldap_server.c46
-rw-r--r--source4/ldap_server/ldap_server.h3
-rw-r--r--source4/smb_server/smb_server.c21
-rw-r--r--source4/smb_server/smb_server.h3
4 files changed, 19 insertions, 54 deletions
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 11ee72d989..ba72326084 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -41,12 +41,11 @@
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn,
const char *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;
+ if (conn->tls) {
+ talloc_free(conn->tls);
+ conn->tls = NULL;
+ }
+ stream_terminate_connection(conn->connection, reason);
}
/*
@@ -231,14 +230,6 @@ static void ldapsrv_recv(struct stream_connection *c, uint16_t flags)
talloc_get_type(c->private, struct ldapsrv_connection);
packet_recv(conn->packet);
-
- if (conn->terminate) {
- if (conn->tls) {
- talloc_free(conn->tls);
- conn->tls = NULL;
- }
- stream_terminate_connection(conn->connection, conn->terminate);
- }
}
/*
@@ -264,14 +255,6 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
talloc_get_type(c->private, struct ldapsrv_connection);
packet_queue_run(conn->packet);
-
- if (conn->terminate) {
- if (conn->tls) {
- talloc_free(conn->tls);
- conn->tls = NULL;
- }
- stream_terminate_connection(conn->connection, conn->terminate);
- }
}
/*
@@ -304,13 +287,13 @@ static void ldapsrv_accept(struct stream_connection *c)
c->event.fde, NULL, port != 389);
if (!conn->tls) {
ldapsrv_terminate_connection(conn, "ldapsrv_accept: tls_init_server() failed");
- goto done;
+ return;
}
conn->packet = packet_init(conn);
if (conn->packet == NULL) {
ldapsrv_terminate_connection(conn, "out of memory");
- goto done;
+ return;
}
packet_set_private(conn->packet, conn);
packet_set_tls(conn->packet, conn->tls);
@@ -324,35 +307,26 @@ static void ldapsrv_accept(struct stream_connection *c)
/* Connections start out anonymous */
if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, &conn->session_info))) {
ldapsrv_terminate_connection(conn, "failed to setup anonymous session info");
- goto done;
+ return;
}
part = talloc(conn, struct ldapsrv_partition);
if (part == NULL) {
ldapsrv_terminate_connection(conn, "talloc failed");
- goto done;
+ return;
}
part->base_dn = "*"; /* default partition */
part->ops = ldapsrv_get_sldb_partition_ops();
if (!NT_STATUS_IS_OK(part->ops->Init(part, conn))) {
ldapsrv_terminate_connection(conn, "default partition Init failed");
- goto done;
+ return;
}
conn->default_partition = part;
DLIST_ADD_END(conn->partitions, part, struct ldapsrv_partition *);
irpc_add_name(c->msg_ctx, "ldap_server");
-
-done:
- if (conn->terminate) {
- if (conn->tls) {
- talloc_free(conn->tls);
- conn->tls = NULL;
- }
- stream_terminate_connection(conn->connection, conn->terminate);
- }
}
static const struct stream_server_ops ldap_stream_ops = {
diff --git a/source4/ldap_server/ldap_server.h b/source4/ldap_server/ldap_server.h
index 4e0abb4f06..a2039fe7f1 100644
--- a/source4/ldap_server/ldap_server.h
+++ b/source4/ldap_server/ldap_server.h
@@ -33,9 +33,6 @@ struct ldapsrv_connection {
/* are we using gensec wrapping? */
BOOL enable_wrap;
- /* connection should be terminated if non-null */
- const char *terminate;
-
struct packet_context *packet;
};
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index d51dec8db4..bffc19fc72 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -75,7 +75,7 @@ static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob)
*/
void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char *reason)
{
- smb_conn->terminate = reason;
+ stream_terminate_connection(smb_conn->connection, reason);
}
/*
@@ -83,17 +83,12 @@ void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char
*/
static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
{
- struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, struct smbsrv_connection);
+ struct smbsrv_connection *smb_conn = talloc_get_type(conn->private,
+ struct smbsrv_connection);
DEBUG(10,("smbsrv_recv\n"));
packet_recv(smb_conn->packet);
- if (smb_conn->terminate) {
- talloc_free(conn->event.fde);
- conn->event.fde = NULL;
- stream_terminate_connection(smb_conn->connection, smb_conn->terminate);
- return;
- }
/* free up temporary memory */
lp_talloc_free();
@@ -109,7 +104,6 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
packet_queue_run(smb_conn->packet);
}
-
/*
handle socket recv errors
*/
@@ -131,11 +125,14 @@ static void smbsrv_accept(struct stream_connection *conn)
DEBUG(5,("smbsrv_accept\n"));
smb_conn = talloc_zero(conn, struct smbsrv_connection);
- if (!smb_conn) return;
+ if (!smb_conn) {
+ stream_terminate_connection(conn, "out of memory");
+ return;
+ }
smb_conn->packet = packet_init(smb_conn);
- if (smb_conn->packet == NULL) {
- stream_terminate_connection(conn, "out of memory");
+ if (!smb_conn->packet) {
+ smbsrv_terminate_connection(smb_conn, "out of memory");
return;
}
packet_set_private(smb_conn->packet, smb_conn);
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 6a73383480..7f38119f2b 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -295,9 +295,6 @@ struct smbsrv_connection {
uint8_t command;
} *trans_partial;
- /* mark a connection for termination */
- const char *terminate;
-
/* configuration parameters */
struct {
enum security_types security;