svn commit: samba r11636 - in branches/SAMBA_4_0/source: lib/stream libcli/raw

tridge at samba.org tridge at samba.org
Thu Nov 10 11:10:40 GMT 2005


Author: tridge
Date: 2005-11-10 11:10:40 +0000 (Thu, 10 Nov 2005)
New Revision: 11636

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11636

Log:

a bit neater solution to the nt_cancel problem

Modified:
   branches/SAMBA_4_0/source/lib/stream/packet.c
   branches/SAMBA_4_0/source/lib/stream/packet.h
   branches/SAMBA_4_0/source/libcli/raw/clitransport.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/stream/packet.c
===================================================================
--- branches/SAMBA_4_0/source/lib/stream/packet.c	2005-11-10 09:12:36 UTC (rev 11635)
+++ branches/SAMBA_4_0/source/lib/stream/packet.c	2005-11-10 11:10:40 UTC (rev 11636)
@@ -45,6 +45,7 @@
 	BOOL serialise;
 	BOOL processing;
 	BOOL recv_disable;
+	BOOL nofree;
 
 	struct send_element {
 		struct send_element *next, *prev;
@@ -144,7 +145,15 @@
 	pc->initial_read = initial_read;
 }
 
+/*
+  tell the packet system not to steal/free blobs given to packet_send()
+*/
+void packet_set_nofree(struct packet_context *pc)
+{
+	pc->nofree = True;
+}
 
+
 /*
   tell the caller we have an error
 */
@@ -427,8 +436,15 @@
 	DLIST_ADD_END(pc->send_queue, el, struct send_element *);
 	el->blob = blob;
 	el->nsent = 0;
-	talloc_steal(el, blob.data);
 
+	/* if we aren't going to free the packet then we must reference it
+	   to ensure it doesn't disappear before going out */
+	if (pc->nofree) {
+		talloc_reference(el, blob.data);
+	} else {
+		talloc_steal(el, blob.data);
+	}
+
 	EVENT_FD_WRITEABLE(pc->fde);
 
 	return NT_STATUS_OK;

Modified: branches/SAMBA_4_0/source/lib/stream/packet.h
===================================================================
--- branches/SAMBA_4_0/source/lib/stream/packet.h	2005-11-10 09:12:36 UTC (rev 11635)
+++ branches/SAMBA_4_0/source/lib/stream/packet.h	2005-11-10 11:10:40 UTC (rev 11636)
@@ -40,6 +40,7 @@
 void packet_set_event_context(struct packet_context *pc, struct event_context *ev);
 void packet_set_serialise(struct packet_context *pc, struct fd_event *fde);
 void packet_set_initial_read(struct packet_context *pc, uint32_t initial_read);
+void packet_set_nofree(struct packet_context *pc);
 void packet_recv(struct packet_context *pc);
 void packet_recv_disable(struct packet_context *pc);
 void packet_recv_enable(struct packet_context *pc);

Modified: branches/SAMBA_4_0/source/libcli/raw/clitransport.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/raw/clitransport.c	2005-11-10 09:12:36 UTC (rev 11635)
+++ branches/SAMBA_4_0/source/libcli/raw/clitransport.c	2005-11-10 11:10:40 UTC (rev 11636)
@@ -105,6 +105,7 @@
 	packet_set_full_request(transport->packet, packet_full_request_nbt);
 	packet_set_error_handler(transport->packet, smbcli_transport_error);
 	packet_set_event_context(transport->packet, transport->socket->event.ctx);
+	packet_set_nofree(transport->packet);
 
 	smbcli_init_signing(transport);
 
@@ -559,16 +560,6 @@
 		return;
 	}
 
-	/* put it on the socket queue
-	 * - as the buffer is a part of the smbcli_request struct
-	 *   we need to reference it here, because packet_queue_run()
-	 *   will call talloc_free() on it
-	 */
-	if (!talloc_reference(req, req->out.buffer)) {
-		req->state = SMBCLI_REQUEST_ERROR;
-		req->status = NT_STATUS_NO_MEMORY;
-		return;
-	}
 	blob = data_blob_const(req->out.buffer, req->out.size);
 	status = packet_send(req->transport->packet, blob);
 	if (!NT_STATUS_IS_OK(status)) {



More information about the samba-cvs mailing list