Patch to fix dbwrap_record_watch functionality
Volker Lendecke
Volker.Lendecke at SerNet.DE
Thu Nov 29 09:11:58 MST 2012
On Thu, Nov 29, 2012 at 05:00:17PM +0100, Volker Lendecke wrote:
> On Thu, Nov 29, 2012 at 04:55:48PM +0100, Volker Lendecke wrote:
> > 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.
>
> Dump that. Obviously wrong. Sorry.
Next try. The memcpy was missing.
Volker
--
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
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 971190ae74b2fe5a6a89d32e665289ff28b40652 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
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 | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index 701ac9d..d7392a3 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -119,12 +119,13 @@ 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;
}
+ memcpy(ids, value.dptr, value.dsize);
ids[num_ids] = id;
num_ids += 1;
--
1.7.3.4
More information about the samba-technical
mailing list