diff options
author | Simo Sorce <idra@samba.org> | 2004-05-21 16:39:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:53:51 -0500 |
commit | b047b71b45d8a7718373d336b52365f884716b65 (patch) | |
tree | 62c8179799cb08e7746e74416adfb15e409e2f5a /source4/lib/tdb/tdbutil.c | |
parent | 3bf29c1113349ba534ff5f9182dc7ed47017ca64 (diff) | |
download | samba-b047b71b45d8a7718373d336b52365f884716b65.tar.gz samba-b047b71b45d8a7718373d336b52365f884716b65.tar.bz2 samba-b047b71b45d8a7718373d336b52365f884716b65.zip |
r808: fix libtdb build by ifedffing out an smb_panic() and copying over CatchSignal fn from lib/signal changing it's name to TdbCatchSignal
(This used to be commit e1afaa1e9c8de5615030015b1360529b450d2047)
Diffstat (limited to 'source4/lib/tdb/tdbutil.c')
-rw-r--r-- | source4/lib/tdb/tdbutil.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/source4/lib/tdb/tdbutil.c b/source4/lib/tdb/tdbutil.c index 9a0e8b0c44..f0fa048bb6 100644 --- a/source4/lib/tdb/tdbutil.c +++ b/source4/lib/tdb/tdbutil.c @@ -35,6 +35,46 @@ 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 ****************************************************************/ @@ -59,7 +99,7 @@ static int tdb_chainlock_with_timeout_internal(TDB_CONTEXT *tdb, TDB_DATA key, u tdb_set_lock_alarm(&gotalarm); if (timeout) { - CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + TdbCatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); alarm(timeout); } @@ -70,7 +110,7 @@ static int tdb_chainlock_with_timeout_internal(TDB_CONTEXT *tdb, TDB_DATA key, u if (timeout) { alarm(0); - CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); + TdbCatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); if (gotalarm) { tdb_debug(tdb, 0, "tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n", timeout, key.dptr, tdb->name ); @@ -689,11 +729,12 @@ TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT *tdb, const char* pattern) for (key = tdb_firstkey(tdb); key.dptr; key = next) { /* duplicate key string to ensure null-termination */ char *key_str = (char*) strndup(key.dptr, key.dsize); +#if 0 if (!key_str) { tdb_debug(tdb, 0, "tdb_search_keys: strndup() failed!\n"); smb_panic("strndup failed!\n"); } - +#endif tdb_debug(tdb, 18, "checking %s for match to pattern %s\n", key_str, pattern); next = tdb_nextkey(tdb, key); |