[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-805-g7ce1356

Stefan Metzmacher metze at samba.org
Wed Apr 1 14:43:06 GMT 2009


The branch, master has been updated
       via  7ce1356c9f571c55af70bd6b966fe50898c1582d (commit)
       via  794525f3427e5f01656f205504d478318d9620a4 (commit)
      from  ffdc2a3fe8437582ded1c4a3b09a54201519889b (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7ce1356c9f571c55af70bd6b966fe50898c1582d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Mar 28 23:29:23 2009 +0100

    lib/util: fallback to any id in idr_get_new_random()
    
    metze

commit 794525f3427e5f01656f205504d478318d9620a4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Mar 28 23:27:47 2009 +0100

    libcli/cldap: fix memory/resource leak
    
    We need to remove the message id, when a search request is finished
    
    metze

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

Summary of changes:
 lib/util/idtree.c    |    8 ++++++--
 libcli/cldap/cldap.c |    9 ++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/idtree.c b/lib/util/idtree.c
index c8a8b63..0af93a2 100644
--- a/lib/util/idtree.c
+++ b/lib/util/idtree.c
@@ -372,12 +372,16 @@ _PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit)
 
 	/* first try a random starting point in the whole range, and if that fails,
 	   then start randomly in the bottom half of the range. This can only
-	   fail if the range is over half full */
+	   fail if the range is over half full, and finally fallback to any
+	   free id */
 	id = idr_get_new_above(idp, ptr, 1+(generate_random() % limit), limit);
 	if (id == -1) {
 		id = idr_get_new_above(idp, ptr, 1+(generate_random()%(limit/2)), limit);
 	}
-	
+	if (id == -1) {
+		id = idr_get_new_above(idp, ptr, 1, limit);
+	}
+
 	return id;
 }
 
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index 561ae80..d3fb0bb 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -510,6 +510,10 @@ static void cldap_reply_state_destroy(struct tevent_req *req)
 static int cldap_search_state_destructor(struct cldap_search_state *s)
 {
 	if (s->caller.cldap) {
+		if (s->message_id != -1) {
+			idr_remove(s->caller.cldap->searches.idr, s->message_id);
+			s->message_id = -1;
+		}
 		DLIST_REMOVE(s->caller.cldap->searches.list, s);
 		cldap_recvfrom_stop(s->caller.cldap);
 		ZERO_STRUCT(s->caller);
@@ -542,8 +546,12 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
 	if (!req) {
 		return NULL;
 	}
+	ZERO_STRUCTP(state);
 	state->req = req;
 	state->caller.cldap = cldap;
+	state->message_id = -1;
+
+	talloc_set_destructor(state, cldap_search_state_destructor);
 
 	if (io->in.dest_address) {
 		if (cldap->connected) {
@@ -634,7 +642,6 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
 	tevent_req_set_callback(subreq, cldap_search_state_queue_done, req);
 
 	DLIST_ADD_END(cldap->searches.list, state, struct cldap_search_state *);
-	talloc_set_destructor(state, cldap_search_state_destructor);
 
 	return req;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list