summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-02-09 20:58:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:52 -0500
commit297ba8dd9cae200feb017f51c29a6375c7d586b0 (patch)
treece090a89970e10ff731d159631c3a0d21427b976 /source3
parente8783bcd007619b5504bfc9a1000e1b4885fb9f3 (diff)
downloadsamba-297ba8dd9cae200feb017f51c29a6375c7d586b0.tar.gz
samba-297ba8dd9cae200feb017f51c29a6375c7d586b0.tar.bz2
samba-297ba8dd9cae200feb017f51c29a6375c7d586b0.zip
r21263: getpeername() returning -1 is not a reliable indication if a TCP connection is
dead. Might be my code, this rings a very distant bell... Attempt to fix bug # 4372. Volker (This used to be commit 730cc3dc1e332449f3e902217ccb9cc3057b9ef3)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/smbldap.c85
1 files changed, 70 insertions, 15 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index aa039294d2..f3a86b0fb3 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1232,12 +1232,23 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
sizelimit, res);
if (rc != LDAP_SUCCESS) {
char *ld_error = NULL;
+ int ld_errno;
+
+ ldap_get_option(ldap_state->ldap_struct,
+ LDAP_OPT_RESULT_CODE, &ld_errno);
+
ldap_get_option(ldap_state->ldap_struct,
LDAP_OPT_ERROR_STRING, &ld_error);
- DEBUG(10,("Failed search for base: %s, error: %s "
- "(%s)\n", base, ldap_err2string(rc),
- ld_error ? ld_error : "unknown"));
+ DEBUG(10, ("Failed search for base: %s, error: %d (%s) "
+ "(%s)\n", base, ld_errno,
+ ldap_err2string(rc),
+ ld_error ? ld_error : "unknown"));
SAFE_FREE(ld_error);
+
+ if (ld_errno == LDAP_SERVER_DOWN) {
+ ldap_unbind(ldap_state->ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
}
}
@@ -1372,12 +1383,23 @@ int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *at
rc = ldap_modify_s(ldap_state->ldap_struct, utf8_dn, attrs);
if (rc != LDAP_SUCCESS) {
char *ld_error = NULL;
+ int ld_errno;
+
+ ldap_get_option(ldap_state->ldap_struct,
+ LDAP_OPT_RESULT_CODE, &ld_errno);
+
ldap_get_option(ldap_state->ldap_struct,
LDAP_OPT_ERROR_STRING, &ld_error);
- DEBUG(10,("Failed to modify dn: %s, error: %s "
- "(%s)\n", dn, ldap_err2string(rc),
- ld_error ? ld_error : "unknown"));
+ DEBUG(10, ("Failed to modify dn: %s, error: %d (%s) "
+ "(%s)\n", dn, ld_errno,
+ ldap_err2string(rc),
+ ld_error ? ld_error : "unknown"));
SAFE_FREE(ld_error);
+
+ if (ld_errno == LDAP_SERVER_DOWN) {
+ ldap_unbind(ldap_state->ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
}
}
@@ -1404,12 +1426,23 @@ int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs
rc = ldap_add_s(ldap_state->ldap_struct, utf8_dn, attrs);
if (rc != LDAP_SUCCESS) {
char *ld_error = NULL;
+ int ld_errno;
+
+ ldap_get_option(ldap_state->ldap_struct,
+ LDAP_OPT_RESULT_CODE, &ld_errno);
+
ldap_get_option(ldap_state->ldap_struct,
LDAP_OPT_ERROR_STRING, &ld_error);
- DEBUG(10,("Failed to add dn: %s, error: %s "
- "(%s)\n", dn, ldap_err2string(rc),
- ld_error ? ld_error : "unknown"));
+ DEBUG(10, ("Failed to add dn: %s, error: %d (%s) "
+ "(%s)\n", dn, ld_errno,
+ ldap_err2string(rc),
+ ld_error ? ld_error : "unknown"));
SAFE_FREE(ld_error);
+
+ if (ld_errno == LDAP_SERVER_DOWN) {
+ ldap_unbind(ldap_state->ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
}
}
@@ -1436,12 +1469,23 @@ int smbldap_delete(struct smbldap_state *ldap_state, const char *dn)
rc = ldap_delete_s(ldap_state->ldap_struct, utf8_dn);
if (rc != LDAP_SUCCESS) {
char *ld_error = NULL;
+ int ld_errno;
+
+ ldap_get_option(ldap_state->ldap_struct,
+ LDAP_OPT_RESULT_CODE, &ld_errno);
+
ldap_get_option(ldap_state->ldap_struct,
LDAP_OPT_ERROR_STRING, &ld_error);
- DEBUG(10,("Failed to delete dn: %s, error: %s "
- "(%s)\n", dn, ldap_err2string(rc),
- ld_error ? ld_error : "unknown"));
+ DEBUG(10, ("Failed to delete dn: %s, error: %d (%s) "
+ "(%s)\n", dn, ld_errno,
+ ldap_err2string(rc),
+ ld_error ? ld_error : "unknown"));
SAFE_FREE(ld_error);
+
+ if (ld_errno == LDAP_SERVER_DOWN) {
+ ldap_unbind(ldap_state->ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
}
}
@@ -1467,12 +1511,23 @@ int smbldap_extended_operation(struct smbldap_state *ldap_state,
clientctrls, retoidp, retdatap);
if (rc != LDAP_SUCCESS) {
char *ld_error = NULL;
+ int ld_errno;
+
+ ldap_get_option(ldap_state->ldap_struct,
+ LDAP_OPT_RESULT_CODE, &ld_errno);
+
ldap_get_option(ldap_state->ldap_struct,
LDAP_OPT_ERROR_STRING, &ld_error);
- DEBUG(10,("Extended operation failed with error: %s "
- "(%s)\n", ldap_err2string(rc),
- ld_error ? ld_error : "unknown"));
+ DEBUG(10, ("Extended operation failed with error: "
+ "%d (%s) (%s)\n", ld_errno,
+ ldap_err2string(rc),
+ ld_error ? ld_error : "unknown"));
SAFE_FREE(ld_error);
+
+ if (ld_errno == LDAP_SERVER_DOWN) {
+ ldap_unbind(ldap_state->ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
}
}