[SCM] Samba Shared Repository - branch v4-1-test updated

Karolin Seeger kseeger at samba.org
Sun Mar 15 17:26:02 MDT 2015


The branch, v4-1-test has been updated
       via  f244eaa talloc: version 2.1.2
       via  75d7179 talloc: fix _talloc_total_limit_size prototype
       via  763a569 lib: talloc: Test suite for the new destructor reparent logic.
       via  f635357 lib: talloc: Allow destructors to reparent the object they're called on.
       via  2a4ca9d lib: talloc: Fix bug when calling a destructor.
       via  1c2f26b talloc:build: improve detection of srcdir
       via  2a59ff1 talloc: version 2.1.1
       via  38aeda4 talloc/tests: avoid some unused variable warnings
       via  21e38ad talloc: fix compiler warning
       via  43049ba talloc: check for TALLOC_GET_TYPE_ABORT_NOOP
       via  32035b0 talloc: avoid a function call in TALLOC_FREE() if possible.
       via  19a86f6 talloc: inline talloc_get_name()
       via  7e2707e talloc: inline more static functions
       via  b77c479 talloc: Tune talloc_vasprintf
       via  7af07a5 talloc: Update flags in pytalloc-util pkgconfig file
       via  4992a53 Add a basic guide on pytalloc.
       via  88c9bff talloc: Add a warning to talloc_reference() documentation.
       via  2aa1291 talloc: Test the pooled object
       via  0f88b87 talloc: Add talloc_pooled_object
       via  62abe79 talloc: Allow nested pools.
       via  1a70518 talloc: Add a separate pool size
       via  8497337 talloc: Put pool-specific data before the chunk
       via  4e36c2f talloc: Introduce __talloc_with_prefix
       via  a6a4ec7 talloc: Decouple the dual use of chunk->pool
       via  133b1c6 Fix valgrind errors with memmove and talloc pools.
       via  834b7ea Add simple limited pool tests to test_memlimit().
       via  105a903 Remove talloc_memlimit_update(). No longer used.
       via  595a97e Inside _talloc_realloc(), keep track of size changes over malloc/realloc/free.
       via  a1e788b Don't call talloc_memlimit_update() inside _talloc_realloc() when we're just manipulating pool members.
       via  a0b5d06 Fix a conditional check. (size - tc->size > 0) is always true if size and tc->size are unsigned.
       via  2d9ed12 In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
       via  833b365 Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
       via  b1a0927 Update memory limits when we call free() on a pool.
       via  f905053 Change __talloc() to only call talloc_memlimit_check()/talloc_memlimit_grow() on actual malloc allocation.
       via  9a11cc5 Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calculating limit size.
       via  622fecb Remove magic TC_HDR_SIZE handling inside talloc_memlimit_check().
       via  fd0122c Start to fix talloc memlimits with talloc pools.
       via  6d0843d3 s3-winbind: Fix chached user group lookup of trusted domains.
       via  88e22cd spoolss: retrieve published printer GUID if not in registry
       via  40a9097 printing: rework nt_printer_guid_store to return errors
       via  f59d71e printing: add nt_printer_guid_retrieve() helper
       via  27c65e0 printing: split out printer DN and GUID retrieval
      from  359d054 doc-xml: Add 'sharesec' reference to 'access based share enum'

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-1-test


- Log -----------------------------------------------------------------
commit f244eaa9ddbfb8481ca66ddf8e9d757d4d5f9519
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 9 09:07:24 2015 +0100

    talloc: version 2.1.2
    
    Changes:
    - Allow destructors to reparent the object
    - Allow destructors to remove itself
    - Build improvements
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 7bef5e4f0e5ff4a4187f3d63e51a1725ff32b771)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11144
    Memory leak in SMB2 notify handling.
    
    Autobuild-User(v4-1-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-1-test): Mon Mar 16 00:25:52 CET 2015 on sn-devel-104

commit 75d7179dfcd2ded8bfea95972497d7da4d6ab5a4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jan 27 13:07:34 2015 +0100

    talloc: fix _talloc_total_limit_size prototype
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 3929abfc6b5a3ae8a27da57d4dbee9524e3585e3)

commit 763a569b68d42b95f82bc6d2e817862a1b7d74bc
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 3 17:12:32 2015 -0800

    lib: talloc: Test suite for the new destructor reparent logic.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sun Mar  8 20:52:43 CET 2015 on sn-devel-104
    
    (cherry picked from commit 6b0cecee1b864a0589836caf9f5f2892f8cb6926)

commit f635357e5848b9c36a2c095bc11b6420c7106ef1
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 3 17:02:47 2015 -0800

    lib: talloc: Allow destructors to reparent the object they're called on.
    
    If a destructor returns failure (-1) when freeing a child, talloc
    must then reparent the child.
    
    Firstly it tries the owner of any reference, next the parent of the
    current object calling _talloc_free_children_internal(), and finally
    the null context in the last resort.
    
    If a destructor reparented its own object, which can be a very
    desirable thing to do (a destructor can make a decision it isn't
    time to die yet, and as the parent may be going away it might
    want to move itself to longer-term storage) then this new parent
    gets overwritten by the existing reparenting logic.
    
    This patch checks when freeing a child if it already reparented
    itself, and if it did doesn't then overwrite the new parent.
    
    Makes destructors more flexible.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    (cherry picked from commit cc4e5481ea060db7f6d8a83619d859b2e002eb90)

commit 2a4ca9d95cad6fcd1871edfde332e36a1b37f7b7
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Mar 5 12:48:47 2015 -0800

    lib: talloc: Fix bug when calling a destructor.
    
    If the destructor itself calls talloc_set_destructor()
    and returns -1, the new destructor set is overwritten
    by talloc.
    
    Dectect that and leave the new destructor in place.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    (cherry picked from commit 3289a5d84f73bf044e5767a6c47a3f7bf8357c08)

commit 1c2f26b8f85039849260364d46ba0b0d4fff2145
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 20 18:04:44 2014 +0200

    talloc:build: improve detection of srcdir
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit cc86b4107acebf56c7bb17f59dd358615aed57b7)

commit 2a59ff106951cb970173b95bb06501fd96485eb7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 15 14:53:49 2014 +0200

    talloc: version 2.1.1
    
    Changes:
    - documentation updates
    - a fix for pytalloc-util.pc
    - performance improvements here and there
    - fixed compiler warnings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri May 16 19:51:26 CEST 2014 on sn-devel-104
    
    (cherry picked from commit b8e5b68de3cff8d16e4be07fdc2e780d2c3c5750)

commit 38aeda43f70c811ad2279035ecfcec1f0dbad702
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 27 09:28:02 2014 +0100

    talloc/tests: avoid some unused variable warnings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8fbb81923ddf3449b4ad1fa1a562c9fab8c74103)

commit 21e38adce7b52da000a693f5837aba457f8e9bb3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 20 09:58:09 2013 +0100

    talloc: fix compiler warning
    
    This avoids the following warning when using:
    
    CFLAGS="-O3 -g -fstrict-overflow -Wstrict-overflow=5"
    
    ../talloc.c: In Funktion »talloc_is_parent«:
    ../talloc.c:2658:21: Warnung: assuming signed overflow does not occur when
    changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Wstrict-overflow]
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit de822b58476093dc43c27577d2f7074541113cc5)

commit 43049baba55eac249c4772ec3956fed0d039a586
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 5 08:36:13 2013 +0100

    talloc: check for TALLOC_GET_TYPE_ABORT_NOOP
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit eb95fc8866dd1710b4cc2f4a4e1dc9867424def2)

commit 32035b08f65908581d50d2da05d42d356fd4adea
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 4 15:35:37 2013 +0100

    talloc: avoid a function call in TALLOC_FREE() if possible.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b9fcfc6399eab750880ee0b9806311dd351a8ff6)

commit 19a86f656fc9eae09a67be7622bc254b2732eeee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 4 23:22:04 2013 +0100

    talloc: inline talloc_get_name()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 014eecd0b2aead3a160af0d864feddd53c85b580)

commit 7e2707e51c9c41902777ebd6f6c22f42efa88158
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Nov 20 09:57:58 2013 +0100

    talloc: inline more static functions
    
    We need the code to be as fast as possible.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3aa35354724b88acc63f6b4439f7203d10db4e90)

commit b77c479319bf5b764fe217be5c6bef4fbead2d68
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 10 10:45:22 2014 +0100

    talloc: Tune talloc_vasprintf
    
    vsnprintf is significantly more expensive than memcpy. For the
    common case where the string we print is less than a kilobyte, avoid
    the second vsnprintf.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 15 12:49:14 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 593c8103af5a5ed6b3c915369fed5b90efb42c25)

commit 7af07a5c49979048e59d3d5cd29d9348e6d9f0d2
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Fri Apr 4 13:29:39 2014 +0200

    talloc: Update flags in pytalloc-util pkgconfig file
    
    After exapnding, @LIB_RPATH@ will be -Wl,-rpatch,/usr/local/lib if rpath is
    used on install. But "-Wl," will be passed to linker and should not be among
    CFLAGS. Other pkgconfig files have @LIB_RPATH@ in the right place.
        @see commit 735c1cd2da15167748e92ba6de48fdb5169db587
    
    Signed-off-by: Lukas Slebodnik <lslebodn at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Apr  4 23:50:25 CEST 2014 on sn-devel-104
    
    (cherry picked from commit e1df75b5a965829db0c1f76673dcc824447b3ae7)

commit 4992a534827847be03d745738f907c4499e391c3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 27 02:12:02 2013 +0000

    Add a basic guide on pytalloc.
    
    Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
    Reviewed-By: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Jelmer Vernooij <jelmer at samba.org>
    Autobuild-Date(master): Thu Nov 28 02:24:45 CET 2013 on sn-devel-104
    
    (cherry picked from commit 91c1053413e1f309b2d5b215a423f37e3883aa91)

commit 88c9bff47708af3749e979fd96fba5dfeb4ca196
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Oct 14 13:17:12 2013 +0200

    talloc: Add a warning to talloc_reference() documentation.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Kai Blin <kai at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Oct 14 23:05:54 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 2343df451a13115eebfd46f9247ec2ae8c3a85c0)

commit 2aa1291ca517990b392b85890ac23e34fac02971
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 15:30:38 2013 -0700

    talloc: Test the pooled object
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 256d10f5792a37d20cbb45f2af3f8578bd354110)

commit 0f88b87633cae1e89b64a58b65ea746cf9d6426d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 15:15:32 2013 -0700

    talloc: Add talloc_pooled_object
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e82320e5197bcdd0330bc829c0963ad09854a36c)

commit 62abe799b8e3d11f6da0d997c20ba5888156f197
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:52:28 2013 -0700

    talloc: Allow nested pools.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 20ad6d7aa3dc5e7db4d886202f757ac1f68287d4)

commit 1a705185b445e0c4bdb5535eda2711c228ba0bc2
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:20:20 2013 -0700

    talloc: Add a separate pool size
    
    This is necessary to allow talloc pools to be objects on their own. It
    is an incompatible change in the sense that talloc_get_size(pool) now
    returns 0 instead of the pool size. When the talloc_pooled_object()
    call is added, this will start to make sense again.
    
    Maybe we should add a talloc_pool_size call? Or is that overkill?
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit a3d9099d9a96b36df21ee0733adc5210438fe9dc)

commit 849733792bc9f70bcaeb366e1cd3c14ceea8df18
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 14:08:43 2013 -0700

    talloc: Put pool-specific data before the chunk
    
    This is a preparation to make talloc pool real objects themselves.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b87c8fd435d1863d6efcec03830ecd85ddfcd7fb)

commit 4e36c2f3e5f35394d175abfa76ac8dfd17ee40c1
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 12:18:26 2013 -0700

    talloc: Introduce __talloc_with_prefix
    
    This will allow to exchange the extra talloc pool header with the
    talloc_chunk structure
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9887f387a10e94f71790c0c3c7dc5f8cde7e4eb2)

commit a6a4ec715fd8006ce9be6015face741ad1952560
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 6 10:54:43 2013 -0700

    talloc: Decouple the dual use of chunk->pool
    
    If we want nested pools, we will have pools that are pool members. So
    we will have to have a separate "next object" pointer  for pools. As
    we have struct talloc_pool_chunk now, this additional pointer does not
    affect normal talloc objects.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 1334c745e1f2157b66e14f9d8b4f6f7750238717)

commit 133b1c60c16d0cd62e4419424bffb3737b3b50cf
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:20:43 2013 -0700

    Fix valgrind errors with memmove and talloc pools.
    
    bin/smbtorture //127.0.0.1 local.talloc now runs with no valgrind errors.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: "Stefan (metze) Metzmacher" <metze at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Aug 28 02:44:17 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 617c647b8ef562ace589a11a15eb460e6db71f2a)

commit 834b7ea41a948d21d723b39270a74681c9b7e510
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:09:03 2013 -0700

    Add simple limited pool tests to test_memlimit().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit cbfc3efbfd4a3a6f3b031ce8ef375d37f2c545f3)

commit 105a9030864395600eb6341a4f13f43eee6faf63
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:08:33 2013 -0700

    Remove talloc_memlimit_update(). No longer used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 3d0f717d437bb24f430fad788b9eb35e8fe8e0e8)

commit 595a97e554f68bee95414dec91a358a3d7a9bced
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:07:04 2013 -0700

    Inside _talloc_realloc(), keep track of size changes over malloc/realloc/free.
    
    Replace the last use of talloc_memlimit_update() with talloc_memlimit_grow()/
    talloc_memlimit_shrink().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 8e2a543e088cac36a5b6bbab1a6be961fa00cc4d)

commit a1e788b3adfe12fedae6216aee28c332c83496a5
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 13:03:27 2013 -0700

    Don't call talloc_memlimit_update() inside _talloc_realloc() when we're just manipulating pool members.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 314508dd73105138d756f4ca3dfb65f1d368a9f7)

commit a0b5d06271ab6c0a6f03f4eb8a2ca9839b8facf1
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:59:04 2013 -0700

    Fix a conditional check. (size - tc->size > 0) is always true if size and tc->size are unsigned.
    
    Replace with (size > tc->size).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 0fbcfcc824e474874c15d7c0b2ea0df408448906)

commit 2d9ed1297a978abf954b5957e9dd5d62749142ef
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:57:43 2013 -0700

    In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 43860293225d14ca2c339277b42f8705322463ab)

commit 833b3653f30109226e83795c05265ccfa286c2a6
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:54:38 2013 -0700

    Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 6bc190d6dd7fd0ab028c39c1463477a863f6943a)

commit b1a092707ee67de4a8be916e2f5283403ee0290d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:51:20 2013 -0700

    Update memory limits when we call free() on a pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 4dfde7d33e7ac6c94833ecc758baff487ab67e4e)

commit f905053b212c0dbb6132685749c7bb850a621771
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:49:00 2013 -0700

    Change __talloc() to only call talloc_memlimit_check()/talloc_memlimit_grow() on actual malloc allocation.
    
    Don't check the memlimit if the allocation was successful from a pool. We already
    checked the memory limit when we created the pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit a4ebbe73b4b8dcab4d344e693ad9796ec8997f87)

commit 9a11cc54266ad61bb121a3ad33d491cc81b05600
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:46:09 2013 -0700

    Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calculating limit size.
    
    We must only count normal tallocs, or a talloc pool itself.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 4159a78ed7eda340758e22286f16186987a20f2f)

commit 622fecba75d53a8c9c85602da0a09d2011cfb422
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:43:50 2013 -0700

    Remove magic TC_HDR_SIZE handling inside talloc_memlimit_check().
    
    Callers already account for TC_HDR_SIZE, do not add it twice.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 7a6beae68ee3f9a97e9e56f4e24a437839fb3e19)

commit fd0122cc72d161f6b67d3f505e7bd6871445072d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 27 12:36:23 2013 -0700

    Start to fix talloc memlimits with talloc pools.
    
    Add the functions:
    
    talloc_memlimit_grow(), talloc_memlimit_shrink(),
    talloc_memlimit_update_on_free().
    
    as replacements for talloc_memlimit_update().
    The interface to talloc_memlimit_update() is very
    hard to understand and use. The above functions
    are (to me) much clearer.
    
    The goal of these changes is to only update
    the memlimits on malloc/free/realloc, not
    on every pool allocation. That way we only
    count pool creation as allocation from any
    imposed limits, not allocation from an already
    created pool.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit fe790f6cbc9b888a8d613cfb515f0d0c76daad47)

commit 6d0843d3ec711fc2beb34f320331497309419b98
Author: Michael Adam <obnox at samba.org>
Date:   Mon Mar 9 15:15:37 2015 +0100

    s3-winbind: Fix chached user group lookup of trusted domains.
    
    If a user group lookup has aleady been done before with a machine
    account we did always return the incomplete information from the cache.
    This patch makes sure we return the correct group information from the
    netsamlogon cache.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11143
    
    Pair-Programmed-With: Andreas Schneider <asn at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (cherry picked from commit f5d0204bfa1eb641fe7697613c1f773b6a7e65de)

commit 88e22cdb3b1fc8d43b4bd172b7ecb74bd2317c82
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 18 15:14:36 2014 +0000

    spoolss: retrieve published printer GUID if not in registry
    
    When a printer is published, the GUID for the published DN is retrieved
    from the domain controller and stored in the registry.
    When handling a spoolss GetPrinter(level=7) request, the same GUID is
    obtained from the registry and returned to the client.
    
    This change sees the spoolss server query the DC for the published
    printer GUID if it is not present in the registry when handling a
    spoolss GetPrinter(level=7) request.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11018
    
    Pair-Programmed-With: David Disseldorp <ddiss at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    
    (cherry picked from commit a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f)

commit 40a9097649cce1d61bcbc652738ef1c60488d68a
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 18 15:13:27 2014 +0000

    printing: rework nt_printer_guid_store to return errors
    
    Callers can now choose whether or not to ignore errors.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11018
    
    Pair-programmed-with: David Disseldorp <ddiss at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 6595ced146a53dcef9bbd5d2deb82a44c8ce1a1a)

commit f59d71e29c7528cf43e4ed68891e65611add509b
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Dec 18 18:23:11 2014 +0100

    printing: add nt_printer_guid_retrieve() helper
    
    This function connects to the domain controller and retrieves the
    GUID for the corresponding printer DN.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11018
    
    Pair-programmed-with: Andreas Schneider <asn at samba.org>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 38dbd054dc331a441b10fdebbdb4bd0fc51cfc0a)

commit 27c65e05a4b83a474401e2c069cf4ba57a823644
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Dec 18 18:18:21 2014 +0100

    printing: split out printer DN and GUID retrieval
    
    This functions are used for printer publishing.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11018
    
    Pair-programmed-with: Andreas Schneider <asn at samba.org>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 7cabd89789a50d37fc32735968c493092a37e69f)

-----------------------------------------------------------------------

Summary of changes:
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.0.sigs} |   0
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.1.sigs} |   0
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.2.sigs} |   0
 .../ABI/{talloc-2.0.8.sigs => talloc-2.1.0.sigs}   |   1 +
 .../ABI/{talloc-2.0.8.sigs => talloc-2.1.1.sigs}   |   1 +
 .../ABI/{talloc-2.0.8.sigs => talloc-2.1.2.sigs}   |   1 +
 lib/talloc/pytalloc-util.pc.in                     |   4 +-
 lib/talloc/pytalloc.h                              |   3 +
 lib/talloc/pytalloc_guide.txt                      | 153 ++++++
 lib/talloc/talloc.c                                | 610 ++++++++++++++-------
 lib/talloc/talloc.h                                |  54 +-
 lib/talloc/testsuite.c                             | 184 +++++++
 lib/talloc/wscript                                 |   4 +-
 source3/include/nt_printing.h                      |   6 +
 source3/printing/nt_printing_ads.c                 | 312 ++++++++---
 source3/rpc_server/spoolss/srv_spoolss_nt.c        |  20 +-
 source3/winbindd/wb_lookupusergroups.c             |  11 +
 17 files changed, 1070 insertions(+), 294 deletions(-)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.0.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.1.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.2.sigs} (100%)
 copy lib/talloc/ABI/{talloc-2.0.8.sigs => talloc-2.1.0.sigs} (97%)
 copy lib/talloc/ABI/{talloc-2.0.8.sigs => talloc-2.1.1.sigs} (97%)
 copy lib/talloc/ABI/{talloc-2.0.8.sigs => talloc-2.1.2.sigs} (97%)
 create mode 100644 lib/talloc/pytalloc_guide.txt


Changeset truncated at 500 lines:

diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.0.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.0.sigs
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.1.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.1.sigs
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.2.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.2.sigs
diff --git a/lib/talloc/ABI/talloc-2.0.8.sigs b/lib/talloc/ABI/talloc-2.1.0.sigs
similarity index 97%
copy from lib/talloc/ABI/talloc-2.0.8.sigs
copy to lib/talloc/ABI/talloc-2.1.0.sigs
index 15a9e95..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.8.sigs
+++ b/lib/talloc/ABI/talloc-2.1.0.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
diff --git a/lib/talloc/ABI/talloc-2.0.8.sigs b/lib/talloc/ABI/talloc-2.1.1.sigs
similarity index 97%
copy from lib/talloc/ABI/talloc-2.0.8.sigs
copy to lib/talloc/ABI/talloc-2.1.1.sigs
index 15a9e95..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.8.sigs
+++ b/lib/talloc/ABI/talloc-2.1.1.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
diff --git a/lib/talloc/ABI/talloc-2.0.8.sigs b/lib/talloc/ABI/talloc-2.1.2.sigs
similarity index 97%
copy from lib/talloc/ABI/talloc-2.0.8.sigs
copy to lib/talloc/ABI/talloc-2.1.2.sigs
index 15a9e95..eae12cc 100644
--- a/lib/talloc/ABI/talloc-2.0.8.sigs
+++ b/lib/talloc/ABI/talloc-2.1.2.sigs
@@ -4,6 +4,7 @@ _talloc_free: int (void *, const char *)
 _talloc_get_type_abort: void *(const void *, const char *, const char *)
 _talloc_memdup: void *(const void *, const void *, size_t, const char *)
 _talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
 _talloc_realloc: void *(const void *, void *, size_t, const char *)
 _talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
 _talloc_reference_loc: void *(const void *, const void *, const char *)
diff --git a/lib/talloc/pytalloc-util.pc.in b/lib/talloc/pytalloc-util.pc.in
index bc704b4..b7426bb 100644
--- a/lib/talloc/pytalloc-util.pc.in
+++ b/lib/talloc/pytalloc-util.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: pytalloc-util
 Description: Utility functions for using talloc objects with Python
 Version: @TALLOC_VERSION@
-Libs: -L${libdir} -lpytalloc-util
-Cflags: @LIB_RPATH@ -I${includedir}
+Libs: @LIB_RPATH@ -L${libdir} -lpytalloc-util
+Cflags: -I${includedir}
 URL: http://talloc.samba.org/
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index 2d2c57b..5c3876e 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -29,7 +29,10 @@ typedef struct {
 	void *ptr;
 } pytalloc_Object;
 
+/* Return the PyTypeObject for pytalloc_Object. Returns a new reference. */
 PyTypeObject *pytalloc_GetObjectType(void);
+
+/* Check whether a specific object is a talloc Object. */
 int pytalloc_Check(PyObject *);
 
 /* Retrieve the pointer for a pytalloc_object. Like talloc_get_type() 
diff --git a/lib/talloc/pytalloc_guide.txt b/lib/talloc/pytalloc_guide.txt
new file mode 100644
index 0000000..755a52b
--- /dev/null
+++ b/lib/talloc/pytalloc_guide.txt
@@ -0,0 +1,153 @@
+Using talloc in Samba4
+======================
+
+.. contents::
+
+Jelmer Vernooij
+August 2013
+
+The most current version of this document is available at
+   http://samba.org/ftp/unpacked/talloc/pytalloc_guide.txt
+
+pytalloc is a small library that provides glue for wrapping
+talloc-allocated objects from C in Python objects.
+
+What is pytalloc, and what is it not?
+-------------------------------------
+
+pytalloc is merely a helper library - it provides a convenient base type object
+for objects that wrap talloc-maintained memory in C. It won't write your
+bindings for you but it will make it easier to write C bindings that involve
+talloc, and take away some of the boiler plate.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_Object
+
+This is the new base class that all Python objects that wrap talloc pointers
+derive from. It is itself a subclass of the "Object" type that all objects
+in Python derive from.
+
+Note that you will almost never create objects of the pytalloc_Object type
+itself, as they are just opaque pointers that can not be accessed from
+Python. A common pattern is other objects that subclass pytalloc_Object and
+rely on it for their memory management.
+
+Each `pytalloc_Object` wraps two core of information - a talloc context
+and a pointer. The pointer is the actual data that is wrapped. The talloc
+context is used for memory management purposes only; when the wrapping Python object
+goes away, it unlinks the talloc context. The talloc context pointer and the ptr
+can (and often do) have the same value.
+
+Each pytalloc_Object has a custom __repr__ implementation that
+describes that it is a talloc object and the location of the
+pointer it is wrapping. it also has a custom __cmp__/__eq__/__neq__ method that
+compares the pointers the object is wrapping rather than the objects
+themselves (since there can be multiple objects that wrap the same talloc
+pointer).
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyTypeObject *pytalloc_GetObjectType(void)
+
+Obtain a reference to the PyTypeObject for `pytalloc_Object`. The reference
+counter for the object will be incremented, so the caller will have to
+decrement it when it no longer needs it (using `Py_DECREF`).
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-
+int pytalloc_Check(PyObject *)
+
+Check whether a specific object is a talloc Object. Returns non-zero if it is
+a pytalloc_Object and zero otherwise.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+type *pytalloc_get_type(PyObject *py_obj, type)
+
+Retrieve the pointer from a `pytalloc_Object` py_obj. type should be a
+C type, similar to a type passed to `talloc_get_type`.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_get_ptr(PyObject *py_obj)
+
+Retrieve the pointer from a `pytalloc_Object` py_obj. There is no
+type checking - use `pytalloc_get_type` if possible.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+TALLOC_CTX *pytalloc_get_mem_ctx(PyObject *py_obj)
+
+Retrieve the talloc context associated with a pytalloc_Object.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
+
+Create a new Python wrapping object for a talloc pointer and context, with
+py_type as associated Python sub type object.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_reference(PyTypeObject *py_type, void *talloc_ptr)
+
+Create a new Python wrapping object for a talloc pointer, with
+py_type as associated Python sub type object. The pointer will also be used
+as the talloc context.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_new(type, PyTypeObject *typeobj)
+
+Create a new, empty pytalloc_Object with the specified Python type object. type
+should be a C type, similar to talloc_new().
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_CObject_FromTallocPtr(void *);
+
+Create a new pytalloc_Object for an abitrary talloc-maintained C pointer. This will
+use a generic VoidPtr Python type, which just provides an opaque object in
+Python. The caller is responsible for incrementing the talloc reference count before calling
+this function - it will dereference the talloc pointer when it is garbage collected.
+
+Debug function for talloc in Python
+-----------------------------------
+
+The "talloc" module in Python provides a couple of functions that can be used
+to debug issues with objects wrapped by pytalloc.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+report_full(obj?)
+
+Print a full report on a specific object or on all allocated objects by Python.
+Same behaviour as the `talloc_report_full()` function that is provided by
+C talloc.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+enable_null_tracking()
+
+This enables tracking of the NULL memory context without enabling leak
+reporting on exit. Useful for when you want to do your own leak
+reporting call via talloc_report_null_full().
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+pytalloc_total_blocks(obj?)
+
+Return the talloc block count for all allocated objects or a specific object if
+specified.
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 76f0aee..c10fd53 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -235,12 +235,19 @@ struct talloc_memlimit {
 	size_t cur_size;
 };
 
-static bool talloc_memlimit_check(struct talloc_memlimit *limit, size_t size);
-static bool talloc_memlimit_update(struct talloc_memlimit *limit,
-				   size_t old_size, size_t new_size);
+static inline bool talloc_memlimit_check(struct talloc_memlimit *limit, size_t size);
+static inline void talloc_memlimit_grow(struct talloc_memlimit *limit,
+				size_t size);
+static inline void talloc_memlimit_shrink(struct talloc_memlimit *limit,
+				size_t size);
+static inline void talloc_memlimit_update_on_free(struct talloc_chunk *tc);
+
+static inline void _talloc_set_name_const(const void *ptr, const char *name);
 
 typedef int (*talloc_destructor_t)(void *);
 
+struct talloc_pool_hdr;
+
 struct talloc_chunk {
 	struct talloc_chunk *next, *prev;
 	struct talloc_chunk *parent, *child;
@@ -260,17 +267,12 @@ struct talloc_chunk {
 	struct talloc_memlimit *limit;
 
 	/*
-	 * "pool" has dual use:
-	 *
-	 * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
-	 * marks the end of the currently allocated area.
-	 *
-	 * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
+	 * For members of a pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
 	 * is a pointer to the struct talloc_chunk of the pool that it was
 	 * allocated from. This way children can quickly find the pool to chew
 	 * from.
 	 */
-	void *pool;
+	struct talloc_pool_hdr *pool;
 };
 
 /* 16 byte alignment seems to keep everyone happy */
@@ -458,49 +460,58 @@ _PUBLIC_ const char *talloc_parent_name(const void *ptr)
   memory footprint of each talloc chunk by those 16 bytes.
 */
 
-union talloc_pool_chunk {
-	/* This lets object_count nestle into 16-byte padding of talloc_chunk,
-	 * on 32-bit platforms. */
-	struct tc_pool_hdr {
-		struct talloc_chunk c;
-		unsigned int object_count;
-	} hdr;
-	/* This makes it always 16 byte aligned. */
-	char pad[TC_ALIGN16(sizeof(struct tc_pool_hdr))];
+struct talloc_pool_hdr {
+	void *end;
+	unsigned int object_count;
+	size_t poolsize;
 };
 
-static void *tc_pool_end(union talloc_pool_chunk *pool_tc)
+#define TP_HDR_SIZE TC_ALIGN16(sizeof(struct talloc_pool_hdr))
+
+static inline struct talloc_pool_hdr *talloc_pool_from_chunk(struct talloc_chunk *c)
+{
+	return (struct talloc_pool_hdr *)((char *)c - TP_HDR_SIZE);
+}
+
+static inline struct talloc_chunk *talloc_chunk_from_pool(struct talloc_pool_hdr *h)
 {
-	return (char *)pool_tc + TC_HDR_SIZE + pool_tc->hdr.c.size;
+	return (struct talloc_chunk *)((char *)h + TP_HDR_SIZE);
 }
 
-static size_t tc_pool_space_left(union talloc_pool_chunk *pool_tc)
+static inline void *tc_pool_end(struct talloc_pool_hdr *pool_hdr)
 {
-	return (char *)tc_pool_end(pool_tc) - (char *)pool_tc->hdr.c.pool;
+	struct talloc_chunk *tc = talloc_chunk_from_pool(pool_hdr);
+	return (char *)tc + TC_HDR_SIZE + pool_hdr->poolsize;
 }
 
-static void *tc_pool_first_chunk(union talloc_pool_chunk *pool_tc)
+static inline size_t tc_pool_space_left(struct talloc_pool_hdr *pool_hdr)
 {
-	return pool_tc + 1;
+	return (char *)tc_pool_end(pool_hdr) - (char *)pool_hdr->end;
 }
 
 /* If tc is inside a pool, this gives the next neighbour. */
-static void *tc_next_chunk(struct talloc_chunk *tc)
+static inline void *tc_next_chunk(struct talloc_chunk *tc)
 {
 	return (char *)tc + TC_ALIGN16(TC_HDR_SIZE + tc->size);
 }
 
+static inline void *tc_pool_first_chunk(struct talloc_pool_hdr *pool_hdr)
+{
+	struct talloc_chunk *tc = talloc_chunk_from_pool(pool_hdr);
+	return tc_next_chunk(tc);
+}
+
 /* Mark the whole remaining pool as not accessable */
-static void tc_invalidate_pool(union talloc_pool_chunk *pool_tc)
+static inline void tc_invalidate_pool(struct talloc_pool_hdr *pool_hdr)
 {
-	size_t flen = tc_pool_space_left(pool_tc);
+	size_t flen = tc_pool_space_left(pool_hdr);
 
 	if (unlikely(talloc_fill.enabled)) {
-		memset(pool_tc->hdr.c.pool, talloc_fill.fill_value, flen);
+		memset(pool_hdr->end, talloc_fill.fill_value, flen);
 	}
 
 #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
-	VALGRIND_MAKE_MEM_NOACCESS(pool_tc->hdr.c.pool, flen);
+	VALGRIND_MAKE_MEM_NOACCESS(pool_hdr->end, flen);
 #endif
 }
 
@@ -508,10 +519,10 @@ static void tc_invalidate_pool(union talloc_pool_chunk *pool_tc)
   Allocate from a pool
 */
 
-static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
-					      size_t size)
+static inline struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
+						     size_t size, size_t prefix_len)
 {
-	union talloc_pool_chunk *pool_ctx = NULL;
+	struct talloc_pool_hdr *pool_hdr = NULL;
 	size_t space_left;
 	struct talloc_chunk *result;
 	size_t chunk_size;
@@ -521,39 +532,39 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 	}
 
 	if (parent->flags & TALLOC_FLAG_POOL) {
-		pool_ctx = (union talloc_pool_chunk *)parent;
+		pool_hdr = talloc_pool_from_chunk(parent);
 	}
 	else if (parent->flags & TALLOC_FLAG_POOLMEM) {
-		pool_ctx = (union talloc_pool_chunk *)parent->pool;
+		pool_hdr = parent->pool;
 	}
 
-	if (pool_ctx == NULL) {
+	if (pool_hdr == NULL) {
 		return NULL;
 	}
 
-	space_left = tc_pool_space_left(pool_ctx);
+	space_left = tc_pool_space_left(pool_hdr);
 
 	/*
 	 * Align size to 16 bytes
 	 */
-	chunk_size = TC_ALIGN16(size);
+	chunk_size = TC_ALIGN16(size + prefix_len);
 
 	if (space_left < chunk_size) {
 		return NULL;
 	}
 
-	result = (struct talloc_chunk *)pool_ctx->hdr.c.pool;
+	result = (struct talloc_chunk *)((char *)pool_hdr->end + prefix_len);
 
 #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
-	VALGRIND_MAKE_MEM_UNDEFINED(result, size);
+	VALGRIND_MAKE_MEM_UNDEFINED(pool_hdr->end, chunk_size);
 #endif
 
-	pool_ctx->hdr.c.pool = (void *)((char *)result + chunk_size);
+	pool_hdr->end = (void *)((char *)pool_hdr->end + chunk_size);
 
 	result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
-	result->pool = pool_ctx;
+	result->pool = pool_hdr;
 
-	pool_ctx->hdr.object_count++;
+	pool_hdr->object_count++;
 
 	return result;
 }
@@ -561,10 +572,12 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 /*
    Allocate a bit of memory as a child of an existing pointer
 */
-static inline void *__talloc(const void *context, size_t size)
+static inline void *__talloc_with_prefix(const void *context, size_t size,
+					size_t prefix_len)
 {
 	struct talloc_chunk *tc = NULL;
 	struct talloc_memlimit *limit = NULL;
+	size_t total_len = TC_HDR_SIZE + size + prefix_len;
 
 	if (unlikely(context == NULL)) {
 		context = null_context;
@@ -574,6 +587,10 @@ static inline void *__talloc(const void *context, size_t size)
 		return NULL;
 	}
 
+	if (unlikely(total_len < TC_HDR_SIZE)) {
+		return NULL;
+	}
+
 	if (context != NULL) {
 		struct talloc_chunk *ptc = talloc_chunk_from_ptr(context);
 
@@ -581,27 +598,29 @@ static inline void *__talloc(const void *context, size_t size)
 			limit = ptc->limit;
 		}
 
-		if (!talloc_memlimit_check(limit, (TC_HDR_SIZE+size))) {
+		tc = talloc_alloc_pool(ptc, TC_HDR_SIZE+size, prefix_len);
+	}
+
+	if (tc == NULL) {
+		char *ptr;
+
+		/*
+		 * Only do the memlimit check/update on actual allocation.
+		 */
+		if (!talloc_memlimit_check(limit, total_len)) {
 			errno = ENOMEM;
 			return NULL;
 		}
 
-		tc = talloc_alloc_pool(ptc, TC_HDR_SIZE+size);
-	}
-
-	if (tc == NULL) {
-		tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
-		if (unlikely(tc == NULL)) return NULL;
+		ptr = malloc(total_len);
+		if (unlikely(ptr == NULL)) {
+			return NULL;
+		}
+		tc = (struct talloc_chunk *)(ptr + prefix_len);
 		tc->flags = TALLOC_MAGIC;
 		tc->pool  = NULL;
-	}
 
-	if (limit != NULL) {
-		struct talloc_memlimit *l;
-
-		for (l = limit; l != NULL; l = l->upper) {
-			l->cur_size += TC_HDR_SIZE+size;
-		}
+		talloc_memlimit_grow(limit, total_len);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list