svn commit: samba r14796 - in branches/SAMBA_4_0/source/ntvfs/posix: .

tridge at samba.org tridge at samba.org
Thu Mar 30 03:14:39 GMT 2006


Author: tridge
Date: 2006-03-30 03:14:38 +0000 (Thu, 30 Mar 2006)
New Revision: 14796

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

Log:

handle overflows in the notify buffer. The pending events are dumped
and the notify buffer removed


Modified:
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_notify.c


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_notify.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_notify.c	2006-03-30 02:25:38 UTC (rev 14795)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_notify.c	2006-03-30 03:14:38 UTC (rev 14796)
@@ -52,8 +52,22 @@
 	struct ntvfs_request *req;
 	struct smb_notify *info;
 
-	if (pending == NULL) return;
+	if (notify_buffer->current_buffer_size > notify_buffer->max_buffer_size && 
+	    notify_buffer->num_changes != 0) {
+		/* on buffer overflow return no changes and destroys the notify buffer */
+		notify_buffer->num_changes = 0;
+		while (notify_buffer->pending) {
+			pvfs_notify_send(notify_buffer, NT_STATUS_OK);
+		}
+		talloc_free(notify_buffer);
+		return;
+	}
 
+	/* see if there is anyone waiting */
+	if (notify_buffer->pending == NULL) {
+		return;
+	}
+
 	DLIST_REMOVE(notify_buffer->pending, pending);
 
 	req = pending->req;
@@ -67,8 +81,6 @@
 
 	talloc_free(pending);
 
-	DEBUG(0,("sending %d changes\n", info->out.num_changes));
-
 	if (info->out.num_changes != 0) {
 		status = NT_STATUS_OK;
 	}
@@ -96,14 +108,23 @@
 static void pvfs_notify_callback(void *private, const struct notify_event *ev)
 {
 	struct pvfs_notify_buffer *n = talloc_get_type(private, struct pvfs_notify_buffer);
+	size_t len;
 
 	n->changes = talloc_realloc(n, n->changes, struct notify_changes, n->num_changes+1);
 	n->changes[n->num_changes].action = ev->action;
 	n->changes[n->num_changes].name.s = talloc_strdup(n->changes, ev->path);
 	n->num_changes++;
 
-	DEBUG(0,("got notify for '%s' action=%d\n", ev->path, ev->action));
+	/*
+	  work out how much room this will take in the buffer
+	*/
+	len = 12 + strlen_m(ev->path)*2;
+	if (len & 3) {
+		len += 4 - (len & 3);
+	}
+	n->current_buffer_size += len;
 
+	/* send what we have */
 	pvfs_notify_send(n, NT_STATUS_OK);
 }
 
@@ -187,6 +208,8 @@
 		NT_STATUS_NOT_OK_RETURN(status);
 	}
 
+	f->notify_buffer->max_buffer_size = info->in.buffer_size;
+
 	pending = talloc(f->notify_buffer, struct notify_pending);
 	NT_STATUS_HAVE_NO_MEMORY(pending);
 



More information about the samba-cvs mailing list