diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:39:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:39:13 +0930 |
commit | 88ce92b92efe12f8a7364eb1786d73ec8ecd7884 (patch) | |
tree | f6fa74c2f88ec480826200a6557c72188c0f79d9 /lib | |
parent | bdd46e4513c7157a67408fcbd1e24b822cdbb960 (diff) | |
download | samba-88ce92b92efe12f8a7364eb1786d73ec8ecd7884.tar.gz samba-88ce92b92efe12f8a7364eb1786d73ec8ecd7884.tar.bz2 samba-88ce92b92efe12f8a7364eb1786d73ec8ecd7884.zip |
tdb2: suppress tdb1 backend logging when locking returns EINTR or EAGAIN
The TDB1 code logs multiple times on errors; we must prevent that in
the limited case where locking fails. With TDB2, this can happen due
to the lock function attribute, where the user supplies replacement
locking functions which are allowed to return with errno EAGAIN or
EINTR for various special-effects. Flooding the logs for this is
unfriendly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit a391b2b900bc6d5c0467869a454bdb5c51b5a3be)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdb2/tdb1_lock.c | 3 | ||||
-rw-r--r-- | lib/tdb2/tdb1_transaction.c | 23 |
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/tdb2/tdb1_lock.c b/lib/tdb2/tdb1_lock.c index 2252e4791b..6498b71367 100644 --- a/lib/tdb2/tdb1_lock.c +++ b/lib/tdb2/tdb1_lock.c @@ -180,7 +180,8 @@ int tdb1_lock(struct tdb1_context *tdb, int list, int ltype) int ret; ret = tdb1_lock_list(tdb, list, ltype, TDB_LOCK_WAIT); - if (ret) { + /* Don't log for EAGAIN and EINTR: they could have overridden lock fns */ + if (ret && errno != EAGAIN && errno != EINTR) { tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, "tdb1_lock failed on list %d " "ltype=%d (%s)", list, ltype, strerror(errno)); diff --git a/lib/tdb2/tdb1_transaction.c b/lib/tdb2/tdb1_transaction.c index 8d25f96ab5..9c526fb41e 100644 --- a/lib/tdb2/tdb1_transaction.c +++ b/lib/tdb2/tdb1_transaction.c @@ -478,8 +478,11 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb) /* get a read lock from the freelist to the end of file. This is upgraded to a write lock during the commit */ if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, true) == -1) { - tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, - "tdb1_transaction_start: failed to get hash locks"); + if (errno != EAGAIN && errno != EINTR) { + tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, + "tdb1_transaction_start:" + " failed to get hash locks"); + } goto fail_allrecord_lock; } @@ -955,9 +958,11 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb) /* upgrade the main transaction lock region to a write lock */ if (tdb1_allrecord_upgrade(tdb) == -1) { - tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, - "tdb1_transaction_prepare_commit:" - " failed to upgrade hash locks"); + if (errno != EAGAIN && errno != EINTR) { + tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, + "tdb1_transaction_prepare_commit:" + " failed to upgrade hash locks"); + } _tdb1_transaction_cancel(tdb); return -1; } @@ -965,9 +970,11 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb) /* get the open lock - this prevents new users attaching to the database during the commit */ if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) { - tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, - "tdb1_transaction_prepare_commit:" - " failed to get open lock"); + if (errno != EAGAIN && errno != EINTR) { + tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, + "tdb1_transaction_prepare_commit:" + " failed to get open lock"); + } _tdb1_transaction_cancel(tdb); return -1; } |