View | Details | Raw Unified | Return to bug 47587 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-directory-listener/src/cache.c (-2 / +19 lines)
 Lines 397-403   int cache_get_master_entry(CacheMasterEntry *master_entry) { Link Here 
397
	return MDB_SUCCESS;
397
	return MDB_SUCCESS;
398
}
398
}
399
399
400
int cache_update_master_entry(CacheMasterEntry *master_entry) {
400
int cache_update_master_entry(CacheMasterEntry *master_entry, int retry) {
401
	int rv;
401
	int rv;
402
	MDB_txn *write_txn;
402
	MDB_txn *write_txn;
403
	MDB_val key, data;
403
	MDB_val key, data;
 Lines 426-432   int cache_update_master_entry(CacheMasterEntry *master_entry) { Link Here 
426
	univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ALL, "cache_update_master_entry: Transaction commit");
426
	univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ALL, "cache_update_master_entry: Transaction commit");
427
	if ((rv = mdb_txn_commit(write_txn)) != MDB_SUCCESS) {
427
	if ((rv = mdb_txn_commit(write_txn)) != MDB_SUCCESS) {
428
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_update_master_entry: storing master entry in database failed");
428
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_update_master_entry: storing master entry in database failed");
429
		ERROR_MDB_ABORT(rv, "mdb_txn_commit");
429
		if (rv == MDB_PAGE_NOTFOUND && retry == 1) {
430
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_update_master_entry: retrying");
431
			cache_mdb_close();
432
433
			/* TODO: pass these paths properly !! */
434
			char cache_dir[PATH_MAX] = "/var/lib/univention-directory-listener";
435
			char cache_mdb_dir[PATH_MAX];
436
437
			rv = snprintf(cache_mdb_dir, PATH_MAX, "%s/cache", cache_dir);
438
			if (rv < 0 || rv >= PATH_MAX)
439
				abort();
440
441
			if (cache_init(cache_mdb_dir, 0) != 0)
442
				exit(1);
443
			cache_update_master_entry(master_entry, 0);
444
		} else {
445
			ERROR_MDB_ABORT(rv, "mdb_txn_commit");
446
		}
430
		return rv;
447
		return rv;
431
	}
448
	}
432
449
(-)a/management/univention-directory-listener/src/cache.h (-1 / +1 lines)
 Lines 46-52   int cache_lock(void); Link Here 
46
int cache_init(char *cache_mdb_dir, int mdb_flags);
46
int cache_init(char *cache_mdb_dir, int mdb_flags);
47
void cache_sync(void);
47
void cache_sync(void);
48
int cache_get_master_entry(CacheMasterEntry *master_entry);
48
int cache_get_master_entry(CacheMasterEntry *master_entry);
49
int cache_update_master_entry(CacheMasterEntry *master_entry);
49
int cache_update_master_entry(CacheMasterEntry *master_entry, int retry);
50
int cache_update_entry(NotifierID id, char *dn, CacheEntry *entry);
50
int cache_update_entry(NotifierID id, char *dn, CacheEntry *entry);
51
int cache_update_entry_lower(NotifierID id, char *dn, CacheEntry *entry);
51
int cache_update_entry_lower(NotifierID id, char *dn, CacheEntry *entry);
52
int cache_delete_entry(NotifierID id, char *dn);
52
int cache_delete_entry(NotifierID id, char *dn);
(-)a/management/univention-directory-listener/src/main.c (-1 / +1 lines)
 Lines 587-593   int main(int argc, char *argv[]) { Link Here 
587
587
588
		cache_get_schema_id(&cache_master_entry.schema_id, 0);
588
		cache_get_schema_id(&cache_master_entry.schema_id, 0);
589
589
590
		rv = cache_update_master_entry(&cache_master_entry);
590
		rv = cache_update_master_entry(&cache_master_entry, 0);
591
	}
591
	}
592
	if (rv != 0)
592
	if (rv != 0)
593
		return rv;
593
		return rv;
(-)a/management/univention-directory-listener/src/notifier.c (-1 / +1 lines)
 Lines 239-245   int notifier_listen(univention_ldap_parameters_t *lp, bool write_transaction_fil Link Here 
239
			goto out;
239
			goto out;
240
240
241
		cache_master_entry.id = id;
241
		cache_master_entry.id = id;
242
		cache_update_master_entry(&cache_master_entry);
242
		cache_update_master_entry(&cache_master_entry, 1);
243
		if (cache_set_int("notifier_id", id))
243
		if (cache_set_int("notifier_id", id))
244
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "failed to write notifier ID");
244
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "failed to write notifier ID");
245
		change_free_transaction_op(&trans.cur);
245
		change_free_transaction_op(&trans.cur);

Return to bug 47587