Age | Commit message (Collapse) | Author | Files | Lines |
|
on systems that have the intptr_t type, and for systems that don't
have it, they also almost certainly won't have -Wcast-qual, so we can use a
void* cast.
(This used to be commit 2132d38f9c5ba59825558d5ba084a514ebc2626b)
|
|
- Some LDB updates
(This used to be commit 4b5bf739f5a8f39ff3633d738f6de42681a6b30f)
|
|
(This used to be commit f4860afc486da9fcd43798c81181d01eb0120a59)
|
|
(This used to be commit 4bb410756df13c8c23d21b43c1186f3f9cb9f758)
|
|
- switch the fallback case tables to use talloc
- moved the used-once octal_string() inline in loadparm.c
(This used to be commit b04202eaacc87d264d463f75673ee0e68cd54f94)
|
|
this is very usefull we you don't want to use smb_panic()
metze
(This used to be commit 343b575baa528885f76be12b2cd707f092f85189)
|
|
of associated functions.
The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)
The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.
While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.
The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:
size_t count_chars(const char *s, char c)
{
size_t count = 0;
while (*s) {
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) count++;
s += size;
}
return count;
}
(This used to be commit 814881f0e50019196b3aa9fbe4aeadbb98172040)
|
|
so talloc now doesn't contain any ldb specific functions.
allow NULL to be passed to a couple more talloc() functions
(This used to be commit 1246f80d806fb5f63cfbf3879de6d546384552a8)
|
|
which is much clearer and simpler to use. It removes a specific parent
from a pointer, no matter whether that parent is a "reference" or a
direct parent. This gives complete control over the free process.
(This used to be commit 6c563887f1b9b8c842309a523e88b6f2a32db10f)
|
|
(This used to be commit 9a04664531601b8251dbf6a0922ab48e675adb90)
|
|
note that this is not just an optimisation, it fixes a rare edge case
when LANMAN1 is negotiated
(This used to be commit 8d879cf54c2fe09d62a5c28b02a070cb80984744)
|
|
match w2k behaviour for older negotiated protocols.
(This used to be commit bae2baeb0247ae8f840b3d3b5488c98d081789c5)
|
|
(This used to be commit 06c58ad221ec40e46310e847ebf640bd53e8e468)
|
|
the % coverage in terms of lines of code of a test suite. I thought a
good first place to start with gcov was the talloc test suite. When I
started the test suite covered about 60% of all lines of code in
talloc.c, and now it covers about 99%. The only lines not covered are
talloc corruption errors, as that would cause smb_panic() to fire.
It will be interesting to try gcov on the main Samba test suite for
smbd. We won't achieve 100% coverage, but it would be nice to get to
90% or more.
I also modified the talloc.c sources to be able to be build standalone, using:
gcc -c -D_STANDALONE_ -Iinlcude lib/talloc.c
that should make it much easier to re-use talloc in other projects
(This used to be commit 8d4dc99b82efdf24b6811851c7bdd4af5a4c52c9)
|
|
- made the LOCAL-TALLOC smbtorture test much stricter, checking that
block counts for every pointer are correct after every operation
(This used to be commit 18d3e2647f0bedbba699d1ba2649c0cfe4526ef6)
|
|
might not place the pointer in the context specified in the docs. The
code was assuming that pointer was at the head of the child list,
which it may not be, depending on what other operations have happened
in between.
(This used to be commit e62bd7ef7ec80365ab00ce5b2051b7dc1726304b)
|
|
subtree. Useful when cleaning up a mess after testing.
(This used to be commit 476674af5519960300c0a07349c7cdf307af3822)
|
|
(This used to be commit 19925f5bd8dd24742e5d216b0c491975ceb7d3a6)
|
|
server
without changing realms
(This used to be commit fd2725f5c0a2ea89bbfcb0403d1bc03fa7b7ec25)
|
|
- added documentation for talloc_unreference()
- made the abandoned child logic in talloc_free() clearer and more consistent
(This used to be commit a87584c8e3fb06cd3ff29a918f681b5c6c32b9ff)
|
|
(This used to be commit b0c92616fb69d8139f66dc8144cfcc88ea6825dc)
|
|
(This used to be commit 3f776a9b5c240312f161b651201458e43a9dd6a9)
|
|
The problem was that the simple "uint_t ref_count;" in a talloc chunk
did not give enough information. It told us that a pointer was
referenced more than once, but it didn't say who it was referenced
by. This means that when the pointer was freed we had no sane way to
clean up the reference.
I have now replaced ref_count with a "refs" list, which means that
references point to the pointer, and the pointer has a linked list of
references. So now we can cleanup from either direction without losing track of anything.
I've also added a LOCAL-TALLOC smbtorture test that tests talloc
behaviour for some common uses.
(This used to be commit 911a8d590cb184bcb892810729955c2c4cf02550)
|
|
metze
(This used to be commit d1e8b340a9942553ec7f281affd11ea4315ac448)
|
|
multibyte
sequences)
(This used to be commit b90da2337b83eb261a8072f9d0b13ec28caf3c4d)
|
|
(This used to be commit f3844cc0a5ad6b03f166435d44db02763df345d7)
|
|
circular references (circular references are allowed, they just need
to be handled carefully inside talloc)
- mark talloc_reference() pointers nicely in the --leak-report-full
code, so you see what has a reference to what in a useful manner
(This used to be commit a87d3d11344069284604a7294a54cadcc6e1a096)
|
|
void *talloc_reference(const void *context, const void *ptr);
this function makes a secondary reference to ptr, and hangs it off the
given context. This greatly simplifies some of the current reference
counting code in the samr server and I suspect it will be widely used
in other places too.
the way you use it is like this:
domain_state->connect_state = talloc_reference(domain_state, connect_state);
that makes the element connect_state of domain_state a secondary
reference to connect_state. The connect_state structure will then only
be freed when both domain_state and the original connect_state go
away, allowing you to free them independently and in any order.
you could do this alrady using a talloc destructor, and that is what
the samr server did previously, but that meant this construct was
being reinvented in several places. So this convenience function sets
up the destructor for you, giving a much more convenient and less
error prone API.
(This used to be commit dc5315086156644fad093cbe6b02d999adba8540)
|
|
a const pointer really means that "the data pointed to by this pointer
won't change", and that is certainly true of talloc(). The fact that
some behind-the-scenes meta-data can change doesn't matter from the
point of view of const.
this fixes a number of const warnings caused by const data structures
being passed as talloc contexts. That will no longer generate a
warning.
also changed the talloc leak reporting option from --leak-check to
--leak-report, as all it does is generate a report on exit. A new
--leak-report-full option has been added that shows the complete tree
of memory allocations, which is is quite useful in tracking things down.
NOTE: I find it quite useful to insert talloc_report_full(ptr, stderr)
calls at strategic points in the code while debugging memory
allocation problems, particularly before freeing a major context (such
as the connection context). This allows you to see if that context has
been accumulating too much data, such as per-request data, which
should have been freed when the request finished.
(This used to be commit c60ff99c3129c26a9204bac1c6e5fb386114a923)
|
|
call name
(This used to be commit 015db2ed8cdde6d6eb79857cb9b6d72185382acc)
|
|
taking a context (so when you pass a NULL pointer you end up with
memory in a top level context). Fixed it by changing the API to take a
context. The context is only used if the pointer you are reallocing is
NULL.
(This used to be commit 8dc23821c9f54b2f13049b5e608a0cafb81aa540)
|
|
and 4.0 don't accept declarations of static functions inside other
functions, see http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02514.html
(This used to be commit 8768168aadf51b9559831954e349d9aa94101c41)
|
|
(This used to be commit 00518201754dc2de583267071ebd2adecbadcb59)
|
|
- talloc_strdup() and related functions get automatic names
(This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)
|
|
to get auto-naming of pointers very cheaply.
- fixed a couple of memory leaks found with the new tricks
A typical exit report for smbd is now:
talloc report on 'null_context' (total 811 bytes in 54 blocks)
auth/auth_sam.c:334 contains 20 bytes in 1 blocks
struct auth_serversupplied_info contains 498 bytes in 33 blocks
UNNAMED contains 8 bytes in 1 blocks
lib/data_blob.c:40 contains 16 bytes in 1 blocks
iconv(CP850,UTF8) contains 61 bytes in 4 blocks
iconv(UTF8,CP850) contains 61 bytes in 4 blocks
iconv(UTF8,UTF-16LE) contains 67 bytes in 4 blocks
iconv(UTF-16LE,UTF8) contains 67 bytes in 4 blocks
UNNAMED contains 13 bytes in 1 blocks
which is much better than before
(This used to be commit 6e721393d03afd3c2f8ced8422533547a9e33342)
|
|
library are closed on abnormal termination
- convert the service.h structures to the new talloc methods
(This used to be commit 2dc334a3284858eb1c7190f9687c9b6c879ecc9d)
|
|
(This used to be commit bc779cb2ce6bc13157f9d046400ce99d107ccd52)
|
|
(This used to be commit 28dcd2202948b003f8d13951395baa4a722593f4)
|
|
auto-derived from the type you are allocating. This is done with
basically zero overhead by relying on the stringify operator in cpp
producing string constants.
the result is that --leak-check nicely names all pointers that come
from talloc_p()
(This used to be commit bd86ebe2972af4d424df20db1e422919aa6203d0)
|
|
and can't properly handle leaks of doubly linked lists which we use a
lot (as the memory is always reachable). Even with --show-reachable
its hard to track leaks down sometimes.
I realised that talloc does have the necessary information to track
these, and by using the cascading property of the new talloc it can
report on leaks in a much more succinct fashion than valgrind can.
I have added a new samba option --leak-check that applies to all Samba
tools. When enabled it prints a leak report summarising all top level
contexts that are present when the program exits. A typical report
looks like this:
talloc report on 'null_context' (total 1071 bytes in 52 blocks)
iconv(CP850,UTF8) contains 43 bytes in 3 blocks
UNNAMED contains 24 bytes in 1 blocks
UNNAMED contains 24 bytes in 1 blocks
dcesrv_init contains 604 bytes in 26 blocks
server_service contains 120 bytes in 6 blocks
UNNAMED contains 24 bytes in 1 blocks
UNNAMED contains 24 bytes in 1 blocks
server_service contains 104 bytes in 4 blocks
server_context contains 12 bytes in 2 blocks
iconv(UTF8,UTF-16LE) contains 46 bytes in 3 blocks
iconv(UTF-16LE,UTF8) contains 46 bytes in 3 blocks
the numbers are recursive summaries for all the memory hanging off each context.
this option is not thread safe when used, but the code is thread safe
if the option is not given, so I don't think thats a problem.
(This used to be commit 96d33d36a5639e7fc46b14a470ccac674d87c62a)
|
|
(This used to be commit 480636ebbca102172621609496bdab682d4bda8a)
|
|
handle unless we use it. This saves quite a bit of memory (libc chews
a lot loading a handle). Typically smbd now loads 3 handles, instead
of 36.
(This used to be commit 60e8d154fda548862cd6f8e8c1dadd64b3c4bd9c)
|
|
(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)
|
|
const warnings for a long time, and no real way to approach a
solution. Some of them are unavoidable due to the way the C standard
works (for example, any function that provides strchr() like
functionality _must_ produce a const warning)
I will be converting a bunch of places that currently produce const
warnings to use the discard_const_p(). Some of these will be
unavoidable const problems, some of them will be ones we will fix up
over time. At least this change means we will no longer be swamped
with const warnings, and we will easily be able to see when new
problems emerge.
(This used to be commit fec3288ad6ce58e8273e3f16e88037db49ecf046)
|
|
(This used to be commit 2a7e5f07086ef4aebbb2be35acbf9c7c39b13c75)
|
|
hierarchical memory allocation
(This used to be commit 26da45a8019a2d6c9ff2ac2a6739c7d0b42b00de)
|
|
compilers
(This used to be commit c2be7b696ccb338df06a5212ed1f7b78e4c116c2)
|
|
need to add MSG_WAITALL to the recv() flags. This is needed by the
current server code or sometimes it will fail with a receive error.
(This used to be commit 4cb11fb77acf74ab53bf5782a114151965c558f0)
|
|
write_data and read_data, which are inherently blocking operations
- got rid of some old NBT keepalive routines that are not needed
(This used to be commit e73b4ae4e500d3b7ee57e160e0f8b63c99b2542a)
|
|
(This used to be commit e502b276ae5e4e22e31a522c4d9e346996d6e29f)
|