|
Lines 88-94
char *cache_dir = "/var/lib/univention-directory-listener";
Link Here
|
| 88 |
char *ldap_dir = "/var/lib/univention-ldap"; |
88 |
char *ldap_dir = "/var/lib/univention-ldap"; |
| 89 |
|
89 |
|
| 90 |
DB *dbp; |
90 |
DB *dbp; |
| 91 |
DBC *dbc_cur = NULL; |
|
|
| 92 |
#ifdef WITH_DB42 |
91 |
#ifdef WITH_DB42 |
| 93 |
DB_ENV *dbenvp; |
92 |
DB_ENV *dbenvp; |
| 94 |
#endif |
93 |
#endif |
|
Lines 138-151
int cache_init(void)
Link Here
|
| 138 |
return -1 ; |
137 |
return -1 ; |
| 139 |
} |
138 |
} |
| 140 |
|
139 |
|
| 141 |
if (lockf(fileno(lock_fp), F_TEST, 0) != 0) { |
140 |
if (lockf(fileno(lock_fp), F_TLOCK, 0) != 0) { |
| 142 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, |
141 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, |
| 143 |
"Could not get lock for database [%s]; " |
142 |
"Could not get lock for database [%s]; " |
| 144 |
"Is another listener processs running?\n", |
143 |
"Is another listener processs running?\n", |
| 145 |
lock_file); |
144 |
lock_file); |
| 146 |
exit(0); |
145 |
exit(0); |
| 147 |
} |
146 |
} |
| 148 |
lockf(fileno(lock_fp), F_LOCK, 0); |
|
|
| 149 |
|
147 |
|
| 150 |
#ifdef WITH_DB42 |
148 |
#ifdef WITH_DB42 |
| 151 |
if ((rv = db_env_create(&dbenvp, 0)) != 0) { |
149 |
if ((rv = db_env_create(&dbenvp, 0)) != 0) { |
|
Lines 579-585
int cache_first_entry(DBC **cur, char **dn, CacheEntry *entry)
Link Here
|
| 579 |
dbp->err(dbp, rv, "cursor"); |
577 |
dbp->err(dbp, rv, "cursor"); |
| 580 |
return rv; |
578 |
return rv; |
| 581 |
} |
579 |
} |
| 582 |
dbc_cur=*cur; |
|
|
| 583 |
|
580 |
|
| 584 |
return cache_next_entry(cur, dn, entry); |
581 |
return cache_next_entry(cur, dn, entry); |
| 585 |
} |
582 |
} |
|
Lines 654-660
int cache_next_entry(DBC **cur, char **dn, CacheEntry *entry)
Link Here
|
| 654 |
|
651 |
|
| 655 |
int cache_free_cursor(DBC *cur) |
652 |
int cache_free_cursor(DBC *cur) |
| 656 |
{ |
653 |
{ |
| 657 |
dbc_cur = NULL; |
|
|
| 658 |
return cur->c_close(cur); |
654 |
return cur->c_close(cur); |
| 659 |
} |
655 |
} |
| 660 |
|
656 |
|
|
Lines 662-672
int cache_close(void)
Link Here
|
| 662 |
{ |
658 |
{ |
| 663 |
int rv; |
659 |
int rv; |
| 664 |
|
660 |
|
| 665 |
if ( dbc_cur != NULL ) |
|
|
| 666 |
cache_free_cursor(dbc_cur); |
| 667 |
if (dbp && (rv = dbp->close(dbp, 0)) != 0) { |
661 |
if (dbp && (rv = dbp->close(dbp, 0)) != 0) { |
| 668 |
dbp->err(dbp, rv, "close"); |
662 |
dbp->err(dbp, rv, "close"); |
| 669 |
} |
663 |
} |
|
|
664 |
dbp = NULL; |
| 670 |
#ifdef WITH_DB42 |
665 |
#ifdef WITH_DB42 |
| 671 |
if ((rv = dbenvp->close(dbenvp, 0)) != 0) { |
666 |
if ((rv = dbenvp->close(dbenvp, 0)) != 0) { |
| 672 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, |
667 |
univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, |
|
Lines 678-683
int cache_close(void)
Link Here
|
| 678 |
if (rc == 0) { |
673 |
if (rc == 0) { |
| 679 |
fclose(lock_fp); |
674 |
fclose(lock_fp); |
| 680 |
} |
675 |
} |
|
|
676 |
lock_fp = NULL; |
| 681 |
} |
677 |
} |
| 682 |
return rv; |
678 |
return rv; |
| 683 |
} |
679 |
} |