summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-27 04:20:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:20 -0500
commit351ca44e8b3ea8336abba8215dfc1ccb42458384 (patch)
tree2a844c622eef52c401a88c53afa05c38e3543436 /source4/librpc
parent0be5523afbd9fcc2c08afab708fa6df19035f16e (diff)
downloadsamba-351ca44e8b3ea8336abba8215dfc1ccb42458384.tar.gz
samba-351ca44e8b3ea8336abba8215dfc1ccb42458384.tar.bz2
samba-351ca44e8b3ea8336abba8215dfc1ccb42458384.zip
r2674: I have realised that talloc() should have its context marked const, as
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)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/rpc/dcerpc_tcp.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source4/librpc/rpc/dcerpc_tcp.c b/source4/librpc/rpc/dcerpc_tcp.c
index 6940c7705d..e28e939a7a 100644
--- a/source4/librpc/rpc/dcerpc_tcp.c
+++ b/source4/librpc/rpc/dcerpc_tcp.c
@@ -117,6 +117,10 @@ static void tcp_process_recv(struct dcerpc_pipe *p)
struct tcp_private *tcp = p->transport.private;
ssize_t ret;
+ if (tcp->recv.data.data == NULL) {
+ tcp->recv.data = data_blob_talloc(tcp, NULL, MIN_HDR_SIZE);
+ }
+
/* read in the base header to get the fragment length */
if (tcp->recv.received < MIN_HDR_SIZE) {
uint32_t frag_length;
@@ -172,7 +176,8 @@ static void tcp_process_recv(struct dcerpc_pipe *p)
/* we have a full packet */
p->transport.recv_data(p, &tcp->recv.data, NT_STATUS_OK);
-
+ talloc_free(tcp->recv.data.data);
+ tcp->recv.data = data_blob(NULL, 0);
tcp->recv.received = 0;
tcp->recv.pending_count--;
if (tcp->recv.pending_count == 0) {
@@ -358,7 +363,7 @@ NTSTATUS dcerpc_pipe_open_tcp(struct dcerpc_pipe **p,
tcp->event_ctx = event_context_init();
tcp->pending_send = NULL;
tcp->recv.received = 0;
- tcp->recv.data = data_blob_talloc(tcp, NULL, MIN_HDR_SIZE);
+ tcp->recv.data = data_blob(NULL, 0);
tcp->recv.pending_count = 0;
fde.fd = fd;