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

(-)src/cache.h (-6 lines)
 Lines 42-53    Link Here 
42
extern char *cache_dir;
42
extern char *cache_dir;
43
extern char *ldap_dir;
43
extern char *ldap_dir;
44
44
45
typedef struct _CacheMasterEntry {
46
	NotifierID id;
47
	NotifierID schema_id;
48
} CacheMasterEntry;
49
extern CacheMasterEntry cache_master_entry;
50
51
int cache_lock(void);
45
int cache_lock(void);
52
int cache_init(char *cache_mdb_dir, int mdb_flags);
46
int cache_init(char *cache_mdb_dir, int mdb_flags);
53
void cache_sync(void);
47
void cache_sync(void);
(-)src/cache_bdb.c (-7 / +7 lines)
 Lines 89-95    Link Here 
89
char *bdb_cache_dir = "/var/lib/univention-directory-listener";
89
char *bdb_cache_dir = "/var/lib/univention-directory-listener";
90
char *bdb_ldap_dir = "/var/lib/univention-ldap";
90
char *bdb_ldap_dir = "/var/lib/univention-ldap";
91
91
92
BdbCacheMasterEntry bdb_cache_master_entry;
92
CacheMasterEntry cache_master_entry;
93
93
94
DB *dbp;
94
DB *dbp;
95
#ifdef WITH_DB42
95
#ifdef WITH_DB42
 Lines 278-284    Link Here 
278
	return fclose(fp) || (rv != 1);
278
	return fclose(fp) || (rv != 1);
279
}
279
}
280
280
281
int bdb_cache_get_master_entry(BdbCacheMasterEntry *master_entry) {
281
int bdb_cache_get_master_entry(CacheMasterEntry *master_entry) {
282
	DBT key, data;
282
	DBT key, data;
283
	int rv;
283
	int rv;
284
284
 Lines 297-314    Link Here 
297
		return rv;
297
		return rv;
298
	}
298
	}
299
299
300
	if (data.size != sizeof(BdbCacheMasterEntry)) {
300
	if (data.size != sizeof(CacheMasterEntry)) {
301
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "master entry has unexpected length");
301
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "master entry has unexpected length");
302
		return 1;
302
		return 1;
303
	}
303
	}
304
304
305
	memcpy(master_entry, data.data, sizeof(BdbCacheMasterEntry));
305
	memcpy(master_entry, data.data, sizeof(CacheMasterEntry));
306
	free(data.data);
306
	free(data.data);
307
307
308
	return 0;
308
	return 0;
309
}
309
}
310
310
311
int bdb_cache_update_master_entry(BdbCacheMasterEntry *master_entry, DB_TXN *dbtxnp) {
311
int bdb_cache_update_master_entry(CacheMasterEntry *master_entry, DB_TXN *dbtxnp) {
312
	DBT key, data;
312
	DBT key, data;
313
	int rv;
313
	int rv;
314
	int flags;
314
	int flags;
 Lines 320-326    Link Here 
320
	key.size = MASTER_KEY_SIZE;
320
	key.size = MASTER_KEY_SIZE;
321
321
322
	data.data = (void *)master_entry;
322
	data.data = (void *)master_entry;
323
	data.size = sizeof(BdbCacheMasterEntry);
323
	data.size = sizeof(CacheMasterEntry);
324
324
325
#ifdef WITH_DB42
325
#ifdef WITH_DB42
326
	if (dbtxnp == NULL)
326
	if (dbtxnp == NULL)
 Lines 343-349    Link Here 
343
DB_TXN *bdb_cache_new_transaction(NotifierID id, char *dn) {
343
DB_TXN *bdb_cache_new_transaction(NotifierID id, char *dn) {
344
#ifdef WITH_DB42
344
#ifdef WITH_DB42
345
	DB_TXN *dbtxnp;
345
	DB_TXN *dbtxnp;
346
	BdbCacheMasterEntry master_entry;
346
	CacheMasterEntry master_entry;
347
	NotifierID *old_id;
347
	NotifierID *old_id;
348
348
349
	dbenvp->txn_begin(dbenvp, NULL, &dbtxnp, 0);
349
	dbenvp->txn_begin(dbenvp, NULL, &dbtxnp, 0);
(-)src/cache_bdb.h (-8 / +2 lines)
 Lines 41-57    Link Here 
41
extern char *bdb_cache_dir;
41
extern char *bdb_cache_dir;
42
extern char *bdb_ldap_dir;
42
extern char *bdb_ldap_dir;
43
43
44
typedef struct _BdbCacheMasterEntry {
45
	NotifierID id;
46
	NotifierID schema_id;
47
} BdbCacheMasterEntry;
48
extern BdbCacheMasterEntry bdb_cache_master_entry;
49
50
int bdb_cache_lock(void);
44
int bdb_cache_lock(void);
51
int bdb_cache_init(void);
45
int bdb_cache_init(void);
52
void bdb_cache_sync(void);
46
void bdb_cache_sync(void);
53
int bdb_cache_get_master_entry(BdbCacheMasterEntry *master_entry);
47
int bdb_cache_get_master_entry(CacheMasterEntry *master_entry);
54
int bdb_cache_update_master_entry(BdbCacheMasterEntry *master_entry, DB_TXN *dptxnp);
48
int bdb_cache_update_master_entry(CacheMasterEntry *master_entry, DB_TXN *dptxnp);
55
int bdb_cache_update_entry(NotifierID id, char *dn, CacheEntry *entry);
49
int bdb_cache_update_entry(NotifierID id, char *dn, CacheEntry *entry);
56
int bdb_cache_update_entry_lower(NotifierID id, char *dn, CacheEntry *entry);
50
int bdb_cache_update_entry_lower(NotifierID id, char *dn, CacheEntry *entry);
57
int bdb_cache_delete_entry(NotifierID id, char *dn);
51
int bdb_cache_delete_entry(NotifierID id, char *dn);
(-)src/cache_entry.h (+6 lines)
 Lines 40-45    Link Here 
40
40
41
#include "network.h"
41
#include "network.h"
42
42
43
typedef struct _CacheMasterEntry {
44
	NotifierID id;
45
	NotifierID schema_id;
46
} CacheMasterEntry;
47
extern CacheMasterEntry cache_master_entry;
48
43
struct _CacheEntryAttribute {
49
struct _CacheEntryAttribute {
44
	char *name;
50
	char *name;
45
	char **values;
51
	char **values;
(-)src/convert.c (-1 / +16 lines)
 Lines 120-125    Link Here 
120
	if (bdb_cache_init() != 0)
120
	if (bdb_cache_init() != 0)
121
		exit(1);
121
		exit(1);
122
122
123
	printf("Converting listener cache to LMDB\n");
123
	rv = snprintf(cache_mdb_dir, PATH_MAX, "%s/cache", cache_dir);
124
	rv = snprintf(cache_mdb_dir, PATH_MAX, "%s/cache", cache_dir);
124
	if (rv < 0 || rv >= PATH_MAX)
125
	if (rv < 0 || rv >= PATH_MAX)
125
		abort();
126
		abort();
 Lines 126-132    Link Here 
126
	if (cache_init(cache_mdb_dir, 0) != 0)
127
	if (cache_init(cache_mdb_dir, 0) != 0)
127
		exit(1);
128
		exit(1);
128
129
129
	bdb_cache_get_master_entry(&bdb_cache_master_entry);
130
	rv = bdb_cache_get_master_entry(&cache_master_entry);
131
	if (rv) {
132
		printf("notifier_id not found in BDB cache, falling back to notifier_id file\n");
133
		cache_get_int("notifier_id", &cache_master_entry.id, -1);
134
		if (cache_master_entry.id == -1) {
135
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cannot determine current ID");
136
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "Aborting conversion");
137
			return 1;
138
		}
139
140
		printf("schema_id not found in BDB cache, falling back to schema/id/id file\n");
141
		cache_get_schema_id(&cache_master_entry.schema_id, 0);
142
	}
143
	printf("cached notifier_id:\t%ld\n", cache_master_entry.id);
144
	printf("cached schema_id:\t%ld\n", cache_master_entry.schema_id);
130
	rv = cache_update_master_entry(&cache_master_entry);
145
	rv = cache_update_master_entry(&cache_master_entry);
131
146
132
	for (rv = bdb_cache_first_entry(&cur, &dn, &entry); rv != DB_NOTFOUND; rv = bdb_cache_next_entry(&cur, &dn, &entry)) {
147
	for (rv = bdb_cache_first_entry(&cur, &dn, &entry); rv != DB_NOTFOUND; rv = bdb_cache_next_entry(&cur, &dn, &entry)) {

Return to bug 44166