svn commit: samba r23153 - in branches/SAMBA_4_0/source/lib/messaging: .

tridge at samba.org tridge at samba.org
Sat May 26 08:47:27 GMT 2007


Author: tridge
Date: 2007-05-26 08:47:27 +0000 (Sat, 26 May 2007)
New Revision: 23153

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

Log:

a first cut at a fix for the dgram flood problem that volker
found. Not sure this is the best solution, but it should work.

Modified:
   branches/SAMBA_4_0/source/lib/messaging/messaging.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/messaging/messaging.c
===================================================================
--- branches/SAMBA_4_0/source/lib/messaging/messaging.c	2007-05-26 03:24:08 UTC (rev 23152)
+++ branches/SAMBA_4_0/source/lib/messaging/messaging.c	2007-05-26 08:47:27 UTC (rev 23153)
@@ -48,11 +48,12 @@
 	uint32_t num_types;
 	struct idr_context *dispatch_tree;
 	struct messaging_rec *pending;
+	struct messaging_rec *retry_queue;
 	struct irpc_list *irpc;
 	struct idr_context *idr;
 	const char **names;
 	struct timeval start_time;
-
+	struct timed_event *retry_te;
 	struct {
 		struct event_context *ev;
 		struct fd_event *fde;
@@ -83,6 +84,7 @@
 	} *header;
 
 	DATA_BLOB packet;
+	uint32_t retries;
 };
 
 
@@ -168,6 +170,7 @@
 	rec->path          = msg->path;
 	rec->header        = (struct messaging_header *)packet.data;
 	rec->packet        = packet;
+	rec->retries       = 0;
 
 	if (packet.length != sizeof(*rec->header) + rec->header->length) {
 		DEBUG(0,("messaging: bad message header size %d should be %d\n", 
@@ -211,6 +214,26 @@
 }
 
 /*
+  retry backed off messages
+*/
+static void msg_retry_timer(struct event_context *ev, struct timed_event *te, 
+			    struct timeval t, void *private)
+{
+	struct messaging_context *msg = talloc_get_type(private, 
+							struct messaging_context);
+	msg->retry_te = NULL;
+
+	/* put the messages back on the main queue */
+	while (msg->retry_queue) {
+		struct messaging_rec *rec = msg->retry_queue;
+		DLIST_REMOVE(msg->retry_queue, rec);
+		DLIST_ADD_END(msg->pending, rec, struct messaging_rec *);
+	}
+
+	EVENT_FD_WRITEABLE(msg->event.fde);	
+}
+
+/*
   handle a socket write event
 */
 static void messaging_send_handler(struct messaging_context *msg)
@@ -220,8 +243,23 @@
 		NTSTATUS status;
 		status = try_send(rec);
 		if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
+			rec->retries++;
+			if (rec->retries > 3) {
+				/* we're getting continuous write errors -
+				   backoff this record */
+				DLIST_REMOVE(msg->pending, rec);
+				DLIST_ADD_END(msg->retry_queue, rec, 
+					      struct messaging_rec *);
+				if (msg->retry_te == NULL) {
+					msg->retry_te = 
+						event_add_timed(msg->event.ev, msg, 
+								timeval_current_ofs(1, 0), 
+								msg_retry_timer, msg);
+				}
+			}
 			break;
 		}
+		rec->retries = 0;
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(1,("messaging: Lost message from %u to %u of type %u - %s\n", 
 				 rec->header->from.id, rec->header->to.id, rec->header->msg_type, 
@@ -281,6 +319,7 @@
 	rec->path          = msg->path;
 	rec->header        = (struct messaging_header *)packet.data;
 	rec->packet        = packet;
+	rec->retries       = 0;
 
 	if (msize != sizeof(*rec->header) + rec->header->length) {
 		DEBUG(0,("messaging: bad message header size %d should be %d\n", 
@@ -415,6 +454,7 @@
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	rec->retries       = 0;
 	rec->msg              = msg;
 	rec->header           = (struct messaging_header *)rec->packet.data;
 	rec->header->version  = MESSAGING_VERSION;



More information about the samba-cvs mailing list