From bae13fd8c834f79cf42faae0bc963ac96d505baf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 12 May 2006 23:20:39 +0000 Subject: 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) --- source3/libads/cldap.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source3') 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; -- cgit