From dfb0082b45e9a721920fa0da2019b63fbd1160b3 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 23 May 2006 16:16:15 +0000 Subject: - Fix locking while connecting to SMB server --- daemon/ntlm.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'daemon/ntlm.c') diff --git a/daemon/ntlm.c b/daemon/ntlm.c index bb08995..2cd20db 100644 --- a/daemon/ntlm.c +++ b/daemon/ntlm.c @@ -103,13 +103,18 @@ static ntlm_connection_t* makeconnection(ha_request_t* rq, ntlm_context_t* ctx) memset(conn, 0, sizeof(*conn)); - /* - * Open a connection to to the domain controller. I don't think - * we can cache these connections or use them again as opening - * a connection here results in an nonce being generated. - */ - conn->handle = ntlmssp_connect(ctx->server, ctx->backup, - ctx->domain, (char*)conn->nonce); + ha_lock(&g_smblib_mutex); + + /* + * Open a connection to to the domain controller. I don't think + * we can cache these connections or use them again as opening + * a connection here results in an nonce being generated. + */ + conn->handle = ntlmssp_connect(ctx->server, ctx->backup, + ctx->domain, (char*)conn->nonce); + + ha_unlock(&g_smblib_mutex); + if(!conn->handle) { ha_messagex(rq, LOG_ERR, "couldn't connect to the domain server %s (backup: %s)", @@ -128,9 +133,14 @@ static void freeconnection(ha_request_t* rq, ntlm_connection_t* conn) if(conn->handle) { + ha_lock(&g_smblib_mutex); + + ntlmssp_disconnect(conn->handle); + conn->handle = NULL; + + ha_unlock(&g_smblib_mutex); + ha_messagex(rq, LOG_DEBUG, "disconnected from server"); - ntlmssp_disconnect(conn->handle); - conn->handle = NULL; } free(conn); -- cgit v1.2.3