summaryrefslogtreecommitdiff
path: root/source4/lib
AgeCommit message (Collapse)AuthorFilesLines
2007-10-10r2872: got rid of a couple of unused (and horrible) functionsAndrew Tridgell2-244/+0
(This used to be commit 4bb410756df13c8c23d21b43c1186f3f9cb9f758)
2007-10-10r2871: - got rid of the last bits of non-threadsafe data in util_str.oAndrew Tridgell2-23/+7
- switch the fallback case tables to use talloc - moved the used-once octal_string() inline in loadparm.c (This used to be commit b04202eaacc87d264d463f75673ee0e68cd54f94)
2007-10-10r2867: make call_backtrace() publicStefan Metzmacher1-1/+1
this is very usefull we you don't want to use smb_panic() metze (This used to be commit 343b575baa528885f76be12b2cd707f092f85189)
2007-10-10r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots ↵Andrew Tridgell9-752/+759
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)
2007-10-10r2792: got rid of talloc_ldb_alloc() and instead created talloc_realloc_fn(),Andrew Tridgell3-14/+17
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)
2007-10-10r2791: got rid of talloc_unreference() and instead created talloc_unlink(),Andrew Tridgell1-3/+48
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)
2007-10-10r2783: got rid of the unused remote architecture detection codeAndrew Tridgell1-40/+0
(This used to be commit 9a04664531601b8251dbf6a0922ab48e675adb90)
2007-10-10r2776: if there are no wildcard characters then use StrCaseCmp()Andrew Tridgell1-0/+6
note that this is not just an optimisation, it fixes a rare edge case when LANMAN1 is negotiated (This used to be commit 8d879cf54c2fe09d62a5c28b02a070cb80984744)
2007-10-10r2775: rewrote our ms_fnmatch code to be much more efficient, and to exactlyAndrew Tridgell1-154/+121
match w2k behaviour for older negotiated protocols. (This used to be commit bae2baeb0247ae8f840b3d3b5488c98d081789c5)
2007-10-10r2773: allow zero sized array tallocAndrew Tridgell1-4/+2
(This used to be commit 06c58ad221ec40e46310e847ebf640bd53e8e468)
2007-10-10r2744: ben elliston taught me about gcov today, which allows you to measureAndrew Tridgell1-58/+120
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)
2007-10-10r2742: - fixed a bug in talloc_unreference()Andrew Tridgell1-3/+3
- 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)
2007-10-10r2737: fixed up a corner case where talloc_unreference() and talloc_free()Andrew Tridgell1-6/+17
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)
2007-10-10r2726: added a -r option to ldbdel to allow easy delete of a wholeAndrew Tridgell1-3/+39
subtree. Useful when cleaning up a mess after testing. (This used to be commit 476674af5519960300c0a07349c7cdf307af3822)
2007-10-10r2725: fixed ldbtest to give the basedn to ldb_search()Andrew Tridgell1-2/+2
(This used to be commit 19925f5bd8dd24742e5d216b0c491975ceb7d3a6)
2007-10-10r2721: added a -b option to ldbtest so it can be used with the new smbd ldap ↵Andrew Tridgell1-8/+10
server without changing realms (This used to be commit fd2725f5c0a2ea89bbfcb0403d1bc03fa7b7ec25)
2007-10-10r2718: - added a talloc_unreference() function as requested by metze.Andrew Tridgell1-2/+43
- added documentation for talloc_unreference() - made the abandoned child logic in talloc_free() clearer and more consistent (This used to be commit a87584c8e3fb06cd3ff29a918f681b5c6c32b9ff)
2007-10-10r2713: better handling of binary values in index key creationAndrew Tridgell1-1/+1
(This used to be commit b0c92616fb69d8139f66dc8144cfcc88ea6825dc)
2007-10-10r2712: fixed a bug in ldbtest to make it cope with an existing indexAndrew Tridgell1-2/+4
(This used to be commit 3f776a9b5c240312f161b651201458e43a9dd6a9)
2007-10-10r2709: finally solved the talloc reference problem.Andrew Tridgell1-39/+94
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)
2007-10-10r2686: remove unused gtk+ checkStefan Metzmacher1-2/+0
metze (This used to be commit d1e8b340a9942553ec7f281affd11ea4315ac448)
2007-10-10r2684: Free the right talloc context (don't panic when encountering illegal ↵Jelmer Vernooij1-1/+1
multibyte sequences) (This used to be commit b90da2337b83eb261a8072f9d0b13ec28caf3c4d)
2007-10-10r2678: from_name and to_name aren't needed in smb_iconv_tAndrew Tridgell1-3/+0
(This used to be commit f3844cc0a5ad6b03f166435d44db02763df345d7)
2007-10-10r2677: - fixed a bug in the recursive logic talloc_free() when there areAndrew Tridgell1-21/+50
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)
2007-10-10r2675: added a convenience functionAndrew Tridgell1-0/+35
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)
2007-10-10r2674: I have realised that talloc() should have its context marked const, asAndrew Tridgell3-46/+96
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)
2007-10-10r2672: don't call a variable "dup" as that conflicts with a standard system ↵Andrew Tridgell1-3/+3
call name (This used to be commit 015db2ed8cdde6d6eb79857cb9b6d72185382acc)
2007-10-10r2671: we're getting too many errors caused by the talloc_realloc() API notAndrew Tridgell6-20/+18
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)
2007-10-10r2667: Remove forward declaration of static function from function. GCC 3.5 ↵Jelmer Vernooij1-2/+3
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)
2007-10-10r2662: make --leak-check completely silent if not blocks are allocatedAndrew Tridgell1-0/+3
(This used to be commit 00518201754dc2de583267071ebd2adecbadcb59)
2007-10-10r2653: - data_blob() and data_blob_talloc() now get automatic namesAndrew Tridgell2-11/+17
- talloc_strdup() and related functions get automatic names (This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)
2007-10-10r2649: - used some cpp tricks to make users of talloc() and talloc_realloc()Andrew Tridgell2-7/+20
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)
2007-10-10r2646: - use a talloc destructor to ensure that sockets from the new socketAndrew Tridgell2-7/+27
library are closed on abnormal termination - convert the service.h structures to the new talloc methods (This used to be commit 2dc334a3284858eb1c7190f9687c9b6c879ecc9d)
2007-10-10r2644: removed an unused functionAndrew Tridgell1-18/+0
(This used to be commit bc779cb2ce6bc13157f9d046400ce99d107ccd52)
2007-10-10r2642: smb_iconv_t is a pointer, so checks against -1 errors should use a castAndrew Tridgell1-1/+1
(This used to be commit 28dcd2202948b003f8d13951395baa4a722593f4)
2007-10-10r2641: talloc_p() now produces a named talloc pointer, with the nameAndrew Tridgell1-3/+31
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)
2007-10-10r2640: valgrind does a great job on some types of memory leaks, but is slowAndrew Tridgell2-5/+80
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)
2007-10-10r2639: we doon't need the valid_table code, so get rid of itAndrew Tridgell1-56/+0
(This used to be commit 480636ebbca102172621609496bdab682d4bda8a)
2007-10-10r2638: do lazy initialisation of iconv handles, so we don't initialise aAndrew Tridgell1-39/+29
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)
2007-10-10r2634: use discard_const_p() in a few placesAndrew Tridgell3-6/+9
(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)
2007-10-10r2632: a new approach to handling const errors. We have had huge numbers ofAndrew Tridgell2-2/+22
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)
2007-10-10r2631: the strchr family of functions should not return const strings.Andrew Tridgell1-3/+3
(This used to be commit 2a7e5f07086ef4aebbb2be35acbf9c7c39b13c75)
2007-10-10r2628: got rid of some warnings and converted a few more places to use ↵Andrew Tridgell1-1/+1
hierarchical memory allocation (This used to be commit 26da45a8019a2d6c9ff2ac2a6739c7d0b42b00de)
2007-10-10r2623: don't do pointer arithmetic on void*, as it doesn't work with non-GNU ↵Andrew Tridgell1-1/+1
compilers (This used to be commit c2be7b696ccb338df06a5212ed1f7b78e4c116c2)
2007-10-10r2622: to implement the SOCKET_FLAG_BLOCK option in the socket library weAndrew Tridgell1-0/+4
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)
2007-10-10r2621: - now that the client code is non-blocking, we no longer needAndrew Tridgell1-73/+0
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)
2007-10-10r2601: avoid free()ing unallocated memory by mistakeSimo Sorce1-1/+6
(This used to be commit e502b276ae5e4e22e31a522c4d9e346996d6e29f)
2007-10-10r2581: added "hosts allow" and "hosts deny" checking in smbd. I needed thisAndrew Tridgell5-0/+386
as my box keeps getting hit by viruses spreading on my companies internal network, which screws up my debug log badly (sigh). metze, I'm not sure if you think access.c should go in the socket library or not. It is closely tied to the socket functions, but you may prefer it separate. The access.c code is a port from Samba3, but with some cleanups to make it (slighly) less ugly. (This used to be commit 058b2fd99e3957d7d2a9544fd27071f1122eab68)
2007-10-10r2577: - I recently found out that charaters below 0x3F are guaranteed not toAndrew Tridgell1-45/+12
occur as secondary bytes in any multi-byte character set. This allows for a very simple optimisation in strchr_m() and strrchr_m(). It might be a good idea to pick this up for Samba3. - the horrible toktocliplist() is only used in clitar.c, so move it there, to prevent anyone else from being tempted to use it. (This used to be commit 663b7b75ddd838ce547425b07d7ce4d4606fb479)
2007-10-10r2556: fixed the -s one bug that jelmer pointed outAndrew Tridgell1-1/+1
(This used to be commit 03c38477add0c5f78072700615b2c1513cbc7663)