View | Details | Raw Unified | Return to bug 40460
Collapse All | Expand All

(-)a/branches/ucs-4.1/ucs-4.1-0/management/univention-directory-listener/debian/changelog (+6 lines)
 Lines 1-3    Link Here 
1
univention-directory-listener (10.0.0-6) unstable; urgency=low
2
3
  * Bug #40460: Retry LDAP queries on LDAP_SERVER_DOWN
4
5
 -- Philipp Hahn <hahn@univention.de>  Fri, 05 Feb 2016 10:09:45 +0100
6
1
univention-directory-listener (10.0.0-5) unstable; urgency=low
7
univention-directory-listener (10.0.0-5) unstable; urgency=low
2
8
3
  * Bug #40373: Improve UCR variable description
9
  * Bug #40373: Improve UCR variable description
(-)a/branches/ucs-4.1/ucs-4.1-0/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables (+6 lines)
 Lines 39-41   Description[de]=Timeout in Sekunden für lange synchrone LDAP Suchanfragen. Stan Link Here 
39
Description[en]=Timeout in seconds for long running synchronous LDAP search queries. Default: 2h
39
Description[en]=Timeout in seconds for long running synchronous LDAP search queries. Default: 2h
40
Type=int
40
Type=int
41
Categories=service-ln
41
Categories=service-ln
42
43
[listener/ldap/retries]
44
Description[de]=Anzahl der Versuche zum Verbindungsaufbau zum LDAP-Server im Fall von Fehlern. Standard: 5
45
Description[en]=Number of retried to re-connect the LDAP server in case of errors. Default: 5
46
Type=int
47
Categories=service-ln
(-)a/branches/ucs-4.1/ucs-4.1-0/management/univention-directory-listener/src/change.c (-6 / +6 lines)
 Lines 143-149   static int change_init_module(univention_ldap_parameters_t *lp, Handler *handler Link Here 
143
			.tv_usec = 0,
143
			.tv_usec = 0,
144
		};
144
		};
145
		int sizelimit0 = 0;
145
		int sizelimit0 = 0;
146
		if ((rv =  ldap_search_ext_s(lp->ld, (*f)->base, (*f)->scope, (*f)->filter, _attrs, attrsonly1,  serverctrls, clientctrls, &timeout, sizelimit0, &res)) != LDAP_SUCCESS) {
146
		if ((rv = LDAP_RETRY(lp, ldap_search_ext_s(lp->ld, (*f)->base, (*f)->scope, (*f)->filter, _attrs, attrsonly1,  serverctrls, clientctrls, &timeout, sizelimit0, &res)) != LDAP_SUCCESS)) {
147
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not get DNs when initializing %s: %s", handler->name, ldap_err2string(rv));
147
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not get DNs when initializing %s: %s", handler->name, ldap_err2string(rv));
148
			return rv;
148
			return rv;
149
		}
149
		}
 Lines 185-191   static int change_init_module(univention_ldap_parameters_t *lp, Handler *handler Link Here 
185
			if ((rv = cache_get_entry_lower_upper(dns[i].dn, &cache_entry)) == DB_NOTFOUND) { /* XXX */
185
			if ((rv = cache_get_entry_lower_upper(dns[i].dn, &cache_entry)) == DB_NOTFOUND) { /* XXX */
186
				LDAPMessage *res2, *first;
186
				LDAPMessage *res2, *first;
187
				int attrsonly0 = 0;
187
				int attrsonly0 = 0;
188
				if ((rv = ldap_search_ext_s(lp->ld, dns[i].dn, LDAP_SCOPE_BASE, "(objectClass=*)", attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res2)) == LDAP_SUCCESS) {
188
				if ((rv = LDAP_RETRY(lp, ldap_search_ext_s(lp->ld, dns[i].dn, LDAP_SCOPE_BASE, "(objectClass=*)", attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res2)) == LDAP_SUCCESS)) {
189
					first = ldap_first_entry(lp->ld, res2);
189
					first = ldap_first_entry(lp->ld, res2);
190
					cache_new_entry_from_ldap(NULL, &cache_entry, lp->ld, first);
190
					cache_new_entry_from_ldap(NULL, &cache_entry, lp->ld, first);
191
					ldap_msgfree(res2);
191
					ldap_msgfree(res2);
 Lines 381-387   int change_update_schema(univention_ldap_parameters_t *lp) Link Here 
381
	if (new_id > id)
381
	if (new_id > id)
382
#endif
382
#endif
383
	{
383
	{
384
		if ((rv=ldap_search_ext_s(lp->ld, "cn=Subschema", LDAP_SCOPE_BASE, "(objectClass=*)", attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res)) == LDAP_SUCCESS) {
384
		if ((rv = LDAP_RETRY(lp, ldap_search_ext_s(lp->ld, "cn=Subschema", LDAP_SCOPE_BASE, "(objectClass=*)", attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res)) == LDAP_SUCCESS)) {
385
			if ((cur=ldap_first_entry(lp->ld, res)) == NULL) {
385
			if ((cur=ldap_first_entry(lp->ld, res)) == NULL) {
386
				univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "got no entry for schema");
386
				univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "got no entry for schema");
387
				return LDAP_OTHER;
387
				return LDAP_OTHER;
 Lines 524-536   int check_parent_dn(struct transaction *trans, char *dn) Link Here 
524
	}
524
	}
525
525
526
	/* search for parent_dn in local LDAP */
526
	/* search for parent_dn in local LDAP */
527
	rv = ldap_search_ext_s(trans->lp_local->ld, parent_dn, LDAP_SCOPE_BASE, filter, attrs_local, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res);
527
	rv = LDAP_RETRY(trans->lp_local, ldap_search_ext_s(trans->lp_local->ld, parent_dn, LDAP_SCOPE_BASE, filter, attrs_local, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res));
528
	ldap_msgfree(res);
528
	ldap_msgfree(res);
529
	if (rv == LDAP_NO_SUCH_OBJECT) {		/* parent_dn not present in local LDAP */
529
	if (rv == LDAP_NO_SUCH_OBJECT) {		/* parent_dn not present in local LDAP */
530
		rv = check_parent_dn(trans, parent_dn);	/* check if parent of parent_dn is here */
530
		rv = check_parent_dn(trans, parent_dn);	/* check if parent of parent_dn is here */
531
		if (rv == LDAP_SUCCESS) {			/* parent of parent_dn found in local LDAP */
531
		if (rv == LDAP_SUCCESS) {			/* parent of parent_dn found in local LDAP */
532
			/* lookup parent_dn object in remote LDAP */
532
			/* lookup parent_dn object in remote LDAP */
533
			rv = ldap_search_ext_s(trans->lp->ld, parent_dn, LDAP_SCOPE_BASE, filter, attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res);
533
			rv = LDAP_RETRY(trans->lp, ldap_search_ext_s(trans->lp->ld, parent_dn, LDAP_SCOPE_BASE, filter, attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res));
534
			if (rv == LDAP_NO_SUCH_OBJECT) {
534
			if (rv == LDAP_NO_SUCH_OBJECT) {
535
				 univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not find parent container of dn: %s from %s (%s)", dn, trans->lp->host, ldap_err2string(rv));
535
				 univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not find parent container of dn: %s from %s (%s)", dn, trans->lp->host, ldap_err2string(rv));
536
				 if (is_move(trans))
536
				 if (is_move(trans))
 Lines 780-786   retry_dn: Link Here 
780
	}
780
	}
781
781
782
	bool delete = false;
782
	bool delete = false;
783
	rv = ldap_search_ext_s(trans->lp->ld, base, scope, filter, attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res);
783
	rv = LDAP_RETRY(trans->lp, ldap_search_ext_s(trans->lp->ld, base, scope, filter, attrs, attrsonly0, serverctrls, clientctrls, &timeout, sizelimit0, &res));
784
	if (rv == LDAP_NO_SUCH_OBJECT) {
784
	if (rv == LDAP_NO_SUCH_OBJECT) {
785
		delete = true;
785
		delete = true;
786
	} else if (rv == LDAP_SUCCESS) {
786
	} else if (rv == LDAP_SUCCESS) {
(-)a/branches/ucs-4.1/ucs-4.1-0/management/univention-directory-listener/src/utils.c (+9 lines)
 Lines 134-136   bool same_dn(const char *left, const char *right) { Link Here 
134
134
135
	return 0 == result;
135
	return 0 == result;
136
}
136
}
137
138
139
int ldap_retries = -1;
140
141
int get_ldap_retries() {
142
	const int DEFAULT_RETRIES = 5;
143
	int retries = univention_config_get_int("listener/ldap/retries");
144
	return retries < 0 ? DEFAULT_RETRIES : retries;
145
}
(-)a/branches/ucs-4.1/ucs-4.1-0/management/univention-directory-listener/src/utils.h (-1 / +16 lines)
 Lines 32-37   static inline int ldap_timeout_scans() { Link Here 
32
	return timeout < 0 ? DEFAULT_TIMEOUT : timeout;
32
	return timeout < 0 ? DEFAULT_TIMEOUT : timeout;
33
}
33
}
34
34
35
extern int ldap_retries;
36
extern int get_ldap_retries();
37
#define LDAP_RETRY(lp, cmd) \
38
	({ \
39
		int _rv, _retry = 0; \
40
		if (ldap_retries < 0) \
41
			ldap_retries = get_ldap_retries(); \
42
		do { \
43
			_rv = (cmd); \
44
			if (rv != LDAP_SERVER_DOWN) \
45
				break; \
46
			while (_retry < ldap_retries && univention_ldap_open(lp) != LDAP_SUCCESS) \
47
				sleep(1 << _retry++); \
48
		} while (_retry < ldap_retries); \
49
		_rv; \
50
	 })
35
51
36
extern char *lower_utf8(const char *str);
52
extern char *lower_utf8(const char *str);
37
extern bool same_dn(const char *left, const char *right);
53
extern bool same_dn(const char *left, const char *right);
38
- 

Return to bug 40460