Patch to fix dbwrap_record_watch functionality

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Nov 29 08:55:48 MST 2012

Hi (metze?) !

Attached find a patch that fixes dbwrap_record_watch.

This fixes the case when more than one record is waiting
simultaneously for a record to change. dbwrap_record_watch
is called right now in session reconnect, I am not sure it
can happen there that multiple waiters for a record can
happen. If that is possible, this is a patch for 4.0 also.

With best regards,

Volker Lendecke

SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen, mailto:kontakt at
-------------- next part --------------
From 1ca0ec60cd42f1fdd00dd5a17a7c2e822ca84c31 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at>
Date: Thu, 29 Nov 2012 16:45:15 +0100
Subject: [PATCH] dbwrap: Do not rely on dbwrap_record_get_value to return a talloc object

db_tdb_fetch_locked returns the value as part of a larger talloc object
that also contains the key.  This means we can not realloc, but have to
freshly alloc.
 source3/lib/dbwrap/dbwrap_watch.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index 701ac9d..85ccb1e 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -119,8 +119,8 @@ static NTSTATUS dbwrap_record_add_watcher(TDB_DATA w_key, struct server_id id)
 	ids = (struct server_id *)value.dptr;
 	num_ids = value.dsize / sizeof(struct server_id);
-	ids = talloc_realloc(talloc_tos(), ids, struct server_id,
-			     num_ids + 1);
+	ids = talloc_array(talloc_tos(), struct server_id,
+			   num_ids + 1);
 	if (ids == NULL) {
 		status = NT_STATUS_NO_MEMORY;
 		goto fail;

More information about the samba-technical mailing list