svn commit: samba r15558 - branches/SAMBA_3_0/source/libads
trunk/source/libads
gd at samba.org
gd at samba.org
Fri May 12 23:20:42 GMT 2006
Author: gd
Date: 2006-05-12 23:20:39 +0000 (Fri, 12 May 2006)
New Revision: 15558
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15558
Log:
Do not wait endless for a CLDAP reply when the LDAP server is
unavailable; use "ldap timeout" handling.
Jerry, please check.
Guenther
Modified:
branches/SAMBA_3_0/source/libads/cldap.c
trunk/source/libads/cldap.c
Changeset:
Modified: branches/SAMBA_3_0/source/libads/cldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/cldap.c 2006-05-12 23:13:39 UTC (rev 15557)
+++ branches/SAMBA_3_0/source/libads/cldap.c 2006-05-12 23:20:39 UTC (rev 15558)
@@ -165,7 +165,17 @@
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 @@
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;
Modified: trunk/source/libads/cldap.c
===================================================================
--- trunk/source/libads/cldap.c 2006-05-12 23:13:39 UTC (rev 15557)
+++ trunk/source/libads/cldap.c 2006-05-12 23:20:39 UTC (rev 15558)
@@ -165,7 +165,17 @@
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 @@
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;
More information about the samba-cvs
mailing list