summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2007-10-10r2675: added a convenience functionAndrew Tridgell2-47/+46
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 Tridgell6-50/+106
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-10r2673: in the rpc server, free up the old call when we decide to extend anAndrew Tridgell1-1/+3
existing call rather than creating a new one. This prevents call structures hanging around on the rpc connection context until it is closed (This used to be commit c51ca7c0e73b97435c245cd440a4fb979cf6a4f3)
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 Tridgell30-79/+84
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-10r2670: use a destructor to auto-close the samr ldb when the last userAndrew Tridgell1-15/+18
disconnects. Previously the ldb was always kept open. (This used to be commit d78eea9eb8540f137d30aef5fbb397295312eb1b)
2007-10-10r2669: convert make_user_info() and associated functions from malloc to tallocAndrew Tridgell4-56/+70
(This used to be commit 278cef77f083c002d17ecbbe18c20825a380eda3)
2007-10-10r2668: steal the cli pointer into the pipe context so a single free destroys ↵Andrew Tridgell1-1/+2
the cli context too (This used to be commit 417d0c0ba182aab3a3a23db76ff7ac7cbc663cb6)
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-10r2664: fixed the final server leak for normal operation. We now get a clean ↵Andrew Tridgell2-5/+8
report from --leak-check (This used to be commit 1ff41bbcae8dc7514a85d69679e44dc7c5b0342f)
2007-10-10r2663: fix an epmapper server leak - another talloc_realloc(NULL, ) leakAndrew Tridgell1-3/+3
(This used to be commit 2662be3a2be04aa7f4dcfde3453389595bf43496)
2007-10-10r2662: make --leak-check completely silent if not blocks are allocatedAndrew Tridgell1-0/+3
(This used to be commit 00518201754dc2de583267071ebd2adecbadcb59)
2007-10-10r2661: fixed a client side memory leak in the clilist code.Andrew Tridgell1-3/+3
This sort of bug happens quite easily with the new talloc_realloc() interface. talloc_realloc() now looks like this: void *talloc_realloc(void *ptr, size_t size); and if ptr is not NULL then everything is fine. If ptr is NULL then talloc_realloc() presumes you want to allocate in the NULL context, which is probably not what is wanted. For now the solution is to initialise ptr like this: ptr = talloc(mem_ctx, 0); so when the realloc happens it has a context to get hold of. I might change the interface of talloc_realloc() later to prevent this problem in a more robust manner (This used to be commit bd813dfb1b08b586dc71f9cec4eb65b35ea808fe)
2007-10-10r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count()Andrew Tridgell24-139/+285
rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8)
2007-10-10r2659: removed some extraneous debug msgsAndrew Tridgell1-3/+0
(This used to be commit 770aa7e01e68df1fd8538c5b19b63a8545bb0355)
2007-10-10r2658: fixed a couple of error codes found with RAW-CONTEXTAndrew Tridgell1-2/+2
(This used to be commit 18632ec56524f294655d881406c10beb659ddee1)
2007-10-10r2657: if we are already fully authenticated in session setup then the vuid ↵Andrew Tridgell1-6/+3
is ignored (This used to be commit 50d5c638a3710855be67cd41dccc9658d64b70fd)
2007-10-10r2656: moved the seteuid configure tests into the posix backend (these testsAndrew Tridgell3-63/+57
don't actually work yet, that will come later) (This used to be commit 46b790c19da25ba88d29f555f828688bb05e531d)
2007-10-10r2655: fixed an error in the shutdown of the sock->transport->session->treeAndrew Tridgell4-4/+4
smbcli raw context handling (This used to be commit d5fd6388751944f11c34e5124d403d57c8670e3b)
2007-10-10r2654: fixed some more server memory leaks. We are now down to a single leakAndrew Tridgell9-10/+26
of 16 bytes, caused by the 16 byte data_blob in the smb_signing code. (This used to be commit 2f1b788e09686e065d22f621f5c0c585192c6740)
2007-10-10r2653: - data_blob() and data_blob_talloc() now get automatic namesAndrew Tridgell3-11/+20
- talloc_strdup() and related functions get automatic names (This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)
2007-10-10r2650: fixed a memory leak in make_server_info()Andrew Tridgell6-9/+10
(This used to be commit 4aba6e7101041100f7d400abd5e7144b95528fc3)
2007-10-10r2649: - used some cpp tricks to make users of talloc() and talloc_realloc()Andrew Tridgell5-11/+37
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-10r2648: - use a destructor on struct server_connection to simplify theAndrew Tridgell11-66/+51
connection termination cleanup, and to ensure that the event contexts are properly removed for every process model - gave auth_context the new talloc treatment, which removes another source of memory leaks. (This used to be commit 230e1cd777b0fba82dffcbd656cfa23c155d0560)
2007-10-10r2646: - use a talloc destructor to ensure that sockets from the new socketAndrew Tridgell13-38/+43
library are closed on abnormal termination - convert the service.h structures to the new talloc methods (This used to be commit 2dc334a3284858eb1c7190f9687c9b6c879ecc9d)
2007-10-10r2645: converted the NTLMSSP code to the new style of tallocAndrew Tridgell7-107/+68
(This used to be commit b378aae95d4001c4cf4e6e59ed80ee1bd55382ee)
2007-10-10r2644: removed an unused functionAndrew Tridgell1-18/+0
(This used to be commit bc779cb2ce6bc13157f9d046400ce99d107ccd52)
2007-10-10r2643: convert more of the auth subsyystem to the new talloc methods. ThisAndrew Tridgell7-52/+35
also fixes a memory leak found with --leak-check. (This used to be commit f19201ea274f0a542314c61c4af676197bf154ad)
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 Tridgell2-4/+32
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-10r2635: mem_ctx cleanups on the lsa and netlogon pipes in the rpc serverAndrew Tridgell3-50/+19
(This used to be commit 1ee5ed4197f49f12372835f66160801f19ee35a6)
2007-10-10r2634: use discard_const_p() in a few placesAndrew Tridgell5-10/+13
(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)
2007-10-10r2633: fixed some function types in the (unused) print backendAndrew Tridgell1-2/+2
(This used to be commit e9803058ecc0b0f849aee48a077bff4e2c8feaa5)
2007-10-10r2632: a new approach to handling const errors. We have had huge numbers ofAndrew Tridgell3-2/+24
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-10r2630: I missed a couple of places in the gensec talloc conversionAndrew Tridgell1-3/+3
(This used to be commit 7124949140141513193f41bb8491aa6a283efed7)
2007-10-10r2629: convert gensec to the new talloc modelAndrew Tridgell13-45/+40
by making our gensec structures a talloc child of the open connection we can be sure that it will be destroyed when the connection is dropped. (This used to be commit f12ee2f241aab1549bc1d9ca4c35a35a1ca0d09d)
2007-10-10r2628: got rid of some warnings and converted a few more places to use ↵Andrew Tridgell8-15/+17
hierarchical memory allocation (This used to be commit 26da45a8019a2d6c9ff2ac2a6739c7d0b42b00de)
2007-10-10r2627: use the new talloc capabilities in a bunch more places in the rpcAndrew Tridgell11-94/+64
server code. This fixes a number of memory leaks I found when testing with valgrind and smbtorture, as the cascading effect of a talloc_free() ensures that anything derived from the top level object is destroyed on disconnect. (This used to be commit 76d0b8206ce64d6ff4a192979c43dddbec726d6e)
2007-10-10r2626: the symbol gai_error is defined in /usr/include, so don't use that ↵Andrew Tridgell1-4/+4
name in our code (This used to be commit 458f85328850905db8e9808d02898c69b5f9b872)
2007-10-10r2625: use talloc_p, not talloc when possible (when allocating a structure ↵Andrew Tridgell1-1/+1
in particular), as it gives us type checking. (This used to be commit dabc7ddd9f940db414d1c3c7bf3cebcd108fbf6f)
2007-10-10r2624: - save some system calls by only trying read/write operations that ↵Andrew Tridgell1-1/+11
select has indicated are possible - when a socket is dead, don't try to do anything more on it (This used to be commit e95e5c591fcf9c3b7fde7fbdcc1837e22195e0a8)
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 Tridgell3-93/+2
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-10r2618: before we had refererence counts in talloc I added a hack in theAndrew Tridgell5-23/+8
server side request structure to prevent a structing being freed in some circumstances. This change replaces this with the much more robust mechanism of talloc_increase_ref_count(). (This used to be commit 3f7741f178b359f81cc98ef18cd69bf976123e9f)
2007-10-10r2617: add connect testing to the rpc test suiteAndrew Tridgell1-1/+1
(This used to be commit 01a759b62775b447eeb2ad447b12d104caa9bfb4)