From d57aaf5ba60464e5e782353a0879a84f8c70dd32 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 May 2007 02:19:28 +0000 Subject: [PATCH] r22960: added a SOCKET_FLAG_NOCLOSE to allow us to tell the socket layer that we will handle the close of the socket --- source/lib/socket/socket.c | 10 +++++++++- source/lib/socket/socket.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/lib/socket/socket.c b/source/lib/socket/socket.c index d975eae2dc7..548b11ebcc9 100644 --- a/source/lib/socket/socket.c +++ b/source/lib/socket/socket.c @@ -30,7 +30,8 @@ */ static int socket_destructor(struct socket_context *sock) { - if (sock->ops->fn_close) { + if (sock->ops->fn_close && + !(sock->flags & SOCKET_FLAG_NOCLOSE)) { sock->ops->fn_close(sock); } return 0; @@ -547,3 +548,10 @@ _PUBLIC_ void set_socket_options(int fd, const char *options) talloc_free(options_list); } +/* + set some flags on a socket + */ +void socket_set_flags(struct socket_context *sock, unsigned flags) +{ + sock->flags |= flags; +} diff --git a/source/lib/socket/socket.h b/source/lib/socket/socket.h index 025fc7e13da..161f112ca64 100644 --- a/source/lib/socket/socket.h +++ b/source/lib/socket/socket.h @@ -109,6 +109,8 @@ enum socket_state { * is encrypting data. * This modifies the * TESTNONBLOCK case */ +#define SOCKET_FLAG_NOCLOSE 0x00000010 /* don't auto-close on free */ + struct socket_context { enum socket_type type; @@ -196,5 +198,6 @@ NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx, const char *server_address, struct socket_context **result, uint16_t *port); void set_socket_options(int fd, const char *options); +void socket_set_flags(struct socket_context *socket, unsigned flags); #endif /* _SAMBA_SOCKET_H */