summaryrefslogtreecommitdiff
path: root/source3/lib/tdb/common
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/tdb/common')
-rw-r--r--source3/lib/tdb/common/lock.c12
-rw-r--r--source3/lib/tdb/common/tdb_private.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/source3/lib/tdb/common/lock.c b/source3/lib/tdb/common/lock.c
index 22896f5227..43be5d20e1 100644
--- a/source3/lib/tdb/common/lock.c
+++ b/source3/lib/tdb/common/lock.c
@@ -27,6 +27,11 @@
#include "tdb_private.h"
+void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *ptr)
+{
+ tdb->interrupt_sig_ptr = ptr;
+}
+
/* a byte range locking function - return 0 on success
this functions locks/unlocks 1 byte at the specified offset.
@@ -58,6 +63,13 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset,
do {
ret = fcntl(tdb->fd,lck_type,&fl);
+
+ /* Check for a sigalarm break. */
+ if (ret == -1 && errno == EINTR &&
+ tdb->interrupt_sig_ptr &&
+ *tdb->interrupt_sig_ptr) {
+ break;
+ }
} while (ret == -1 && errno == EINTR);
if (ret == -1) {
diff --git a/source3/lib/tdb/common/tdb_private.h b/source3/lib/tdb/common/tdb_private.h
index d2f2c23d72..daef07aff1 100644
--- a/source3/lib/tdb/common/tdb_private.h
+++ b/source3/lib/tdb/common/tdb_private.h
@@ -28,6 +28,7 @@
#include "system/time.h"
#include "system/shmem.h"
#include "system/select.h"
+#include "system/wait.h"
#include "tdb.h"
#ifndef HAVE_GETPAGESIZE
@@ -161,6 +162,7 @@ struct tdb_context {
struct tdb_transaction *transaction;
int page_size;
int max_dead_records;
+ volatile sig_atomic_t *interrupt_sig_ptr;
};