summaryrefslogtreecommitdiff
path: root/source4/libcli/raw/clisocket.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-26 11:30:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:18 -0500
commite3880fa759cfa03222262327854fe7bbe585fe01 (patch)
tree7000172fad1b5cdcc0d071698ee3e203e61a8f4f /source4/libcli/raw/clisocket.c
parentad053090b817105a0974f4b8bf0b90e002297903 (diff)
downloadsamba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.gz
samba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.bz2
samba-e3880fa759cfa03222262327854fe7bbe585fe01.zip
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)
Diffstat (limited to 'source4/libcli/raw/clisocket.c')
-rw-r--r--source4/libcli/raw/clisocket.c28
1 files changed, 15 insertions, 13 deletions
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;
}
@@ -97,18 +111,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.
****************************************************************************/
void smbcli_sock_set_options(struct smbcli_socket *sock, const char *options)