summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/smb_server/smb_server.c13
-rw-r--r--source4/smb_server/smb_server.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index b632bfefd2..d1fdd2b116 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -659,7 +659,7 @@ error:
*/
void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char *reason)
{
- stream_terminate_connection(smb_conn->connection, reason);
+ smb_conn->terminate = True;
}
/*
@@ -684,10 +684,10 @@ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
smb_conn->processing = True;
status = receive_smb_request(smb_conn);
smb_conn->processing = False;
- if (NT_STATUS_IS_ERR(status)) {
+ if (NT_STATUS_IS_ERR(status) || smb_conn->terminate) {
talloc_free(conn->event.fde);
conn->event.fde = NULL;
- smbsrv_terminate_connection(smb_conn, nt_errstr(status));
+ stream_terminate_connection(smb_conn->connection, nt_errstr(status));
return;
}
@@ -717,7 +717,7 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
status = socket_send(conn->socket, &blob, &sendlen, 0);
if (NT_STATUS_IS_ERR(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
- return;
+ break;
}
if (sendlen == 0) {
break;
@@ -733,6 +733,11 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
}
}
+ if (smb_conn->terminate) {
+ stream_terminate_connection(smb_conn->connection, "send termination");
+ return;
+ }
+
/* if no more requests are pending to be sent then
we should stop select for write */
if (smb_conn->pending_send == NULL) {
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 46e480e77c..13dc056f86 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -265,6 +265,9 @@ struct smbsrv_connection {
BOOL processing;
+ /* mark a connection for termination */
+ BOOL terminate;
+
/* configuration parameters */
struct {
enum security_types security;