summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-03-13 01:40:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:03 -0500
commit639edc4097d1d5f011ce642b97b522ac4cb8b4ae (patch)
tree36bd33eaf200e0d8af5d616ab52ff6a1d0aae94c /source4
parent1fb7f63aa9ce8b1b1384a7c907fbe1c0bbc9cd92 (diff)
downloadsamba-639edc4097d1d5f011ce642b97b522ac4cb8b4ae.tar.gz
samba-639edc4097d1d5f011ce642b97b522ac4cb8b4ae.tar.bz2
samba-639edc4097d1d5f011ce642b97b522ac4cb8b4ae.zip
r5779: Remove signal and timeout gubbage from tdb.
(This used to be commit dbb56e9a59cf00d57b09ded6d60bf9424d5f1f4c)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/tdb/common/tdb.c28
-rw-r--r--source4/lib/tdb/common/tdbutil.c102
-rw-r--r--source4/lib/tdb/include/tdb.h1
3 files changed, 4 insertions, 127 deletions
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
index 90b586d487..d9fabaeda9 100644
--- a/source4/lib/tdb/common/tdb.c
+++ b/source4/lib/tdb/common/tdb.c
@@ -61,7 +61,6 @@
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <signal.h>
#include "tdb.h"
#else
#include "includes.h"
@@ -193,18 +192,6 @@ struct list_struct {
*/
};
-/***************************************************************
- Allow a caller to set a "alarm" flag that tdb can check to abort
- a blocking lock on SIGALRM.
-***************************************************************/
-
-static sig_atomic_t *palarm_fired;
-
-void tdb_set_lock_alarm(sig_atomic_t *palarm)
-{
- palarm_fired = palarm;
-}
-
/* a byte range locking function - return 0 on success
this functions locks/unlocks 1 byte at the specified offset.
@@ -231,27 +218,16 @@ static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset,
do {
ret = fcntl(tdb->fd,lck_type,&fl);
- if (ret == -1 && errno == EINTR && palarm_fired && *palarm_fired)
- break;
} while (ret == -1 && errno == EINTR);
if (ret == -1) {
if (!probe && lck_type != F_SETLK) {
/* Ensure error code is set for log fun to examine. */
- if (errno == EINTR && palarm_fired && *palarm_fired)
- tdb->ecode = TDB_ERR_LOCK_TIMEOUT;
- else
- tdb->ecode = TDB_ERR_LOCK;
+ tdb->ecode = TDB_ERR_LOCK;
TDB_LOG((tdb, 5,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d\n",
tdb->fd, offset, rw_type, lck_type));
}
- /* Was it an alarm timeout ? */
- if (errno == EINTR && palarm_fired && *palarm_fired) {
- TDB_LOG((tdb, 5, "tdb_brlock timed out (fd=%d) at offset %d rw_type=%d lck_type=%d\n",
- tdb->fd, offset, rw_type, lck_type));
- return TDB_ERRCODE(TDB_ERR_LOCK_TIMEOUT, -1);
- }
- /* Otherwise - generic lock error. errno set by fcntl.
+ /* Generic lock error. errno set by fcntl.
* EAGAIN is an expected return from non-blocking
* locks. */
if (errno != EAGAIN) {
diff --git a/source4/lib/tdb/common/tdbutil.c b/source4/lib/tdb/common/tdbutil.c
index e3c5641054..3f9b227591 100644
--- a/source4/lib/tdb/common/tdbutil.c
+++ b/source4/lib/tdb/common/tdbutil.c
@@ -29,57 +29,6 @@
/* these are little tdb utility functions that are meant to make
dealing with a tdb database a little less cumbersome in Samba */
-static sig_atomic_t gotalarm;
-
-/***************************************************************
- Signal function to tell us we timed out.
-****************************************************************/
-
-static void gotalarm_sig(void)
-{
- gotalarm = 1;
-}
-
-
-/*******************************************************************
- THIS is a copy of the function CatchSignal found in lib/signal.c
- I need to copy it there to avoid sucking all of the samba source
- into tdb.
-
- Catch a signal. This should implement the following semantics:
-
- 1) The handler remains installed after being called.
- 2) The signal should be blocked during handler execution.
-********************************************************************/
-
-static void (*TdbCatchSignal(int signum,void (*handler)(int )))(int)
-{
-#ifdef HAVE_SIGACTION
- struct sigaction act;
- struct sigaction oldact;
-
- ZERO_STRUCT(act);
-
- act.sa_handler = handler;
-#ifdef SA_RESTART
- /*
- * We *want* SIGALRM to interrupt a system call.
- */
- if(signum != SIGALRM)
- act.sa_flags = SA_RESTART;
-#endif
- sigemptyset(&act.sa_mask);
- sigaddset(&act.sa_mask,signum);
- sigaction(signum,&act,&oldact);
- return oldact.sa_handler;
-#else /* !HAVE_SIGACTION */
- /* FIXME: need to handle sigvec and systems with broken signal() */
- return signal(signum, handler);
-#endif
-}
-
-
-
/***************************************************************
Make a TDB_DATA and keep the const warning in one place
****************************************************************/
@@ -93,53 +42,6 @@ static TDB_DATA make_tdb_data(const char *dptr, size_t dsize)
}
/****************************************************************************
- Lock a chain with timeout (in seconds).
-****************************************************************************/
-
-static int tdb_chainlock_with_timeout_internal(TDB_CONTEXT *tdb, TDB_DATA key, uint_t timeout, int rw_type)
-{
- /* Allow tdb_chainlock to be interrupted by an alarm. */
- int ret;
- gotalarm = 0;
- tdb_set_lock_alarm(&gotalarm);
-
- if (timeout) {
- TdbCatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
- alarm(timeout);
- }
-
- if (rw_type == F_RDLCK)
- ret = tdb_chainlock_read(tdb, key);
- else
- ret = tdb_chainlock(tdb, key);
-
- if (timeout) {
- alarm(0);
- TdbCatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
- if (gotalarm) {
- tdb->log_fn(tdb, 0, "tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
- timeout, key.dptr, tdb->name);
- /* TODO: If we time out waiting for a lock, it might
- * be nice to use F_GETLK to get the pid of the
- * process currently holding the lock and print that
- * as part of the debugging message. -- mbp */
- return -1;
- }
- }
-
- return ret;
-}
-
-/****************************************************************************
- Write lock a chain. Return -1 if timeout or lock failed.
-****************************************************************************/
-
-int tdb_chainlock_with_timeout(TDB_CONTEXT *tdb, TDB_DATA key, uint_t timeout)
-{
- return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
-}
-
-/****************************************************************************
Lock a chain by string. Return -1 if timeout or lock failed.
****************************************************************************/
@@ -147,7 +49,7 @@ int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, uint_t timeout)
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
- return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
+ return tdb_chainlock(tdb, key);
}
/****************************************************************************
@@ -169,7 +71,7 @@ int tdb_read_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, uint_t timeout)
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
- return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_RDLCK);
+ return tdb_chainlock_read(tdb, key);
}
/****************************************************************************
diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h
index 1de5517d91..846b157758 100644
--- a/source4/lib/tdb/include/tdb.h
+++ b/source4/lib/tdb/include/tdb.h
@@ -138,7 +138,6 @@ int tdb_lockall(TDB_CONTEXT *tdb);
void tdb_unlockall(TDB_CONTEXT *tdb);
/* Low level locking functions: use with care */
-void tdb_set_lock_alarm(sig_atomic_t *palarm);
int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key);