mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
tdb: don't alter tdb->flags in tdb_reopen_all()
The flags are user-visible, via tdb_get_flags/add_flags/remove_flags. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Stefan Metzmacher <metze@samba.org> (This used to be ctdb commit 8f48e37c254e0852d4e2dea54b905ce5ef2b925d)
This commit is contained in:
parent
ed2c8e415f
commit
3cc352f975
@ -405,9 +405,7 @@ void *tdb_get_logging_private(struct tdb_context *tdb)
|
|||||||
return tdb->log.log_private;
|
return tdb->log.log_private;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reopen a tdb - this can be used after a fork to ensure that we have an independent
|
static int tdb_reopen_internal(struct tdb_context *tdb, bool active_lock)
|
||||||
seek pointer from our parent and to re-establish locks */
|
|
||||||
int tdb_reopen(struct tdb_context *tdb)
|
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -450,7 +448,7 @@ int tdb_reopen(struct tdb_context *tdb)
|
|||||||
tdb_mmap(tdb);
|
tdb_mmap(tdb);
|
||||||
#endif /* fake pread or pwrite */
|
#endif /* fake pread or pwrite */
|
||||||
|
|
||||||
if ((tdb->flags & TDB_CLEAR_IF_FIRST) &&
|
if (active_lock &&
|
||||||
(tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) {
|
(tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) {
|
||||||
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n"));
|
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n"));
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -463,12 +461,21 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reopen a tdb - this can be used after a fork to ensure that we have an independent
|
||||||
|
seek pointer from our parent and to re-establish locks */
|
||||||
|
int tdb_reopen(struct tdb_context *tdb)
|
||||||
|
{
|
||||||
|
return tdb_reopen_internal(tdb, tdb->flags & TDB_CLEAR_IF_FIRST);
|
||||||
|
}
|
||||||
|
|
||||||
/* reopen all tdb's */
|
/* reopen all tdb's */
|
||||||
int tdb_reopen_all(int parent_longlived)
|
int tdb_reopen_all(int parent_longlived)
|
||||||
{
|
{
|
||||||
struct tdb_context *tdb;
|
struct tdb_context *tdb;
|
||||||
|
|
||||||
for (tdb=tdbs; tdb; tdb = tdb->next) {
|
for (tdb=tdbs; tdb; tdb = tdb->next) {
|
||||||
|
bool active_lock = (tdb->flags & TDB_CLEAR_IF_FIRST);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the parent is longlived (ie. a
|
* If the parent is longlived (ie. a
|
||||||
* parent daemon architecture), we know
|
* parent daemon architecture), we know
|
||||||
@ -482,10 +489,10 @@ int tdb_reopen_all(int parent_longlived)
|
|||||||
*/
|
*/
|
||||||
if (parent_longlived) {
|
if (parent_longlived) {
|
||||||
/* Ensure no clear-if-first. */
|
/* Ensure no clear-if-first. */
|
||||||
tdb->flags &= ~TDB_CLEAR_IF_FIRST;
|
active_lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdb_reopen(tdb) != 0)
|
if (tdb_reopen_internal(tdb, active_lock) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user