diff options
author | Volker Lendecke <vl@samba.org> | 2010-02-15 16:49:46 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2010-04-01 09:39:17 +0200 |
commit | cca616a10771d9eee4b1ff4de14a49bdfaacf867 (patch) | |
tree | b96c4b83ea70b2149be2dc017c9aebf05be0622c /source3/lib | |
parent | 7641f941e73f06171b7a28f7f0a2f79fb003ba30 (diff) | |
download | samba-cca616a10771d9eee4b1ff4de14a49bdfaacf867.tar.gz |
s3: Fix handling of processes that died in g_lock
g_lock_parse might have thrown away entries from the locks array because the
processes were not around anymore. Don't store the orphaned entries.
(cherry picked from commit f3bdb163f461175c50b4930fa3464beaee30f4a8)
(cherry picked from commit b2677d82dc5c6bc76b0343d90ec75972b5b2a8bf)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/g_lock.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index 26b079d3bc0..42c0397189d 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -127,11 +127,12 @@ static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data, static struct g_lock_rec *g_lock_addrec(TALLOC_CTX *mem_ctx, struct g_lock_rec *locks, - int num_locks, + int *pnum_locks, const struct server_id pid, enum g_lock_type lock_type) { struct g_lock_rec *result; + int num_locks = *pnum_locks; result = talloc_realloc(mem_ctx, locks, struct g_lock_rec, num_locks+1); @@ -141,6 +142,7 @@ static struct g_lock_rec *g_lock_addrec(TALLOC_CTX *mem_ctx, result[num_locks].pid = pid; result[num_locks].lock_type = lock_type; + *pnum_locks += 1; return result; } @@ -221,7 +223,7 @@ again: if (our_index == -1) { /* First round, add ourself */ - locks = g_lock_addrec(talloc_tos(), locks, num_locks, + locks = g_lock_addrec(talloc_tos(), locks, &num_locks, self, lock_type); if (locks == NULL) { DEBUG(10, ("g_lock_addrec failed\n")); @@ -237,7 +239,7 @@ again: locks[our_index].lock_type = lock_type; } - data = make_tdb_data((uint8_t *)locks, talloc_get_size(locks)); + data = make_tdb_data((uint8_t *)locks, num_locks * sizeof(*locks)); store_status = rec->store(rec, data, 0); if (!NT_STATUS_IS_OK(store_status)) { DEBUG(1, ("rec->store failed: %s\n", |