svn commit: samba r5779 - in branches/SAMBA_4_0/source/lib/tdb: common include

tpot at samba.org tpot at samba.org
Sun Mar 13 01:40:49 GMT 2005


Author: tpot
Date: 2005-03-13 01:40:45 +0000 (Sun, 13 Mar 2005)
New Revision: 5779

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5779

Log:
Remove signal and timeout gubbage from tdb.

Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
   branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c
   branches/SAMBA_4_0/source/lib/tdb/include/tdb.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2005-03-13 01:01:24 UTC (rev 5778)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2005-03-13 01:40:45 UTC (rev 5779)
@@ -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 @@
 	*/
 };
 
-/***************************************************************
- 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 @@
 
 	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) {

Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c	2005-03-13 01:01:24 UTC (rev 5778)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c	2005-03-13 01:40:45 UTC (rev 5779)
@@ -29,58 +29,7 @@
 /* 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 @@
 }
 
 /****************************************************************************
- 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 @@
 {
 	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 @@
 {
 	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);
 }
 
 /****************************************************************************

Modified: branches/SAMBA_4_0/source/lib/tdb/include/tdb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/include/tdb.h	2005-03-13 01:01:24 UTC (rev 5778)
+++ branches/SAMBA_4_0/source/lib/tdb/include/tdb.h	2005-03-13 01:40:45 UTC (rev 5779)
@@ -138,7 +138,6 @@
 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);



More information about the samba-cvs mailing list