summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2006-05-12 23:20:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:59 -0500
commitbae13fd8c834f79cf42faae0bc963ac96d505baf (patch)
treed84509f9071c86cce3ae7255abb0c01346a87cd7 /source3/libads
parenta041b6b67264acb060aa5cd87e621b82f65659e6 (diff)
downloadsamba-bae13fd8c834f79cf42faae0bc963ac96d505baf.tar.gz
samba-bae13fd8c834f79cf42faae0bc963ac96d505baf.tar.bz2
samba-bae13fd8c834f79cf42faae0bc963ac96d505baf.zip
r15558: Do not wait endless for a CLDAP reply when the LDAP server is
unavailable; use "ldap timeout" handling. Jerry, please check. Guenther (This used to be commit 821bbb4566c4b3f9798054ed3bf772db0c9ae3f2)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/cldap.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c
index 6a62f573c9..775d43dc3f 100644
--- a/source3/libads/cldap.c
+++ b/source3/libads/cldap.c
@@ -165,7 +165,17 @@ static int send_cldap_netlogon(int sock, const char *domain,
return 0;
}
-
+static SIG_ATOMIC_T gotalarm;
+
+/***************************************************************
+ Signal function to tell us we timed out.
+****************************************************************/
+
+static void gotalarm_sig(void)
+{
+ gotalarm = 1;
+}
+
/*
receive a cldap netlogon reply
*/
@@ -180,8 +190,18 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply)
blob = data_blob(NULL, 8192);
+ /* Setup timeout */
+ gotalarm = 0;
+ CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+ alarm(lp_ldap_timeout());
+ /* End setup timeout. */
+
ret = read(sock, blob.data, blob.length);
+ /* Teardown timeout. */
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
+ alarm(0);
+
if (ret <= 0) {
d_fprintf(stderr, "no reply received to cldap netlogon\n");
return -1;