From e3880fa759cfa03222262327854fe7bbe585fe01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:30:20 +0000 Subject: r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count() rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8) --- source4/libcli/raw/clisocket.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source4/libcli/raw/clisocket.c') diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index 8481bc73e2..37188f4e77 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -21,6 +21,18 @@ #include "includes.h" +/* + destroy a socket + */ +static int sock_destructor(void *ptr) +{ + struct smbcli_socket *sock = ptr; + if (sock->fd != -1) { + close(sock->fd); + sock->fd = -1; + } + return 0; +} /* create a smbcli_socket context @@ -37,11 +49,13 @@ struct smbcli_socket *smbcli_sock_init(void) ZERO_STRUCTP(sock); sock->fd = -1; sock->port = 0; + /* 20 second default timeout */ sock->timeout = 20000; - sock->hostname = NULL; + talloc_set_destructor(sock, sock_destructor); + return sock; } @@ -96,18 +110,6 @@ void smbcli_sock_dead(struct smbcli_socket *sock) } } -/**************************************************************************** - reduce socket reference count - if it becomes zero then close -****************************************************************************/ -void smbcli_sock_close(struct smbcli_socket *sock) -{ - sock->reference_count--; - if (sock->reference_count <= 0) { - smbcli_sock_dead(sock); - talloc_free(sock); - } -} - /**************************************************************************** Set socket options on a open connection. ****************************************************************************/ -- cgit