[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1388-gaffed02

Simo Sorce idra at samba.org
Sat Sep 5 10:47:29 MDT 2009


The branch, master has been updated
       via  affed02ef67b495e8785a56545d15eff96d7a749 (commit)
       via  bc081cf0cc41ad8da24cc60c27ab7c7931d60c55 (commit)
      from  0cfc2f19eff04f4d48ba065563238ae18f2e3f5b (commit)

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


- Log -----------------------------------------------------------------
commit affed02ef67b495e8785a56545d15eff96d7a749
Author: Simo Sorce <idra at samba.org>
Date:   Sat Sep 5 10:18:12 2009 -0400

    Check we read off the compelte event from inotify
    
    The kernel may return a short read, so we must use read_data() to make sure we
    read off the full buffer. If somethign bad happens we also need to kill the
    inotify watch because the filedescriptor will return out of sync structures if
    we read only part of the data.

commit bc081cf0cc41ad8da24cc60c27ab7c7931d60c55
Author: Simo Sorce <idra at samba.org>
Date:   Sat Sep 5 10:17:48 2009 -0400

    Save and report the correct errno value.

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

Summary of changes:
 source3/lib/util_sock.c       |   20 ++++++++++++--------
 source3/smbd/notify_inotify.c |   10 ++++++++--
 2 files changed, 20 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index ec88b60..638a92d 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -555,6 +555,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 	size_t nread = 0;
 	struct timeval timeout;
 	char addr[INET6_ADDRSTRLEN];
+	int save_errno;
 
 	/* just checking .... */
 	if (maxcnt <= 0)
@@ -576,19 +577,20 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 			}
 
 			if (readret == -1) {
+				save_errno = errno;
 				if (fd == get_client_fd()) {
 					/* Try and give an error message
 					 * saying what client failed. */
 					DEBUG(0,("read_socket_with_timeout: "
 						"client %s read error = %s.\n",
 						get_peer_addr(fd,addr,sizeof(addr)),
-						strerror(errno) ));
+						strerror(save_errno) ));
 				} else {
 					DEBUG(0,("read_socket_with_timeout: "
 						"read error = %s.\n",
-						strerror(errno) ));
+						strerror(save_errno) ));
 				}
-				return map_nt_error_from_unix(errno);
+				return map_nt_error_from_unix(save_errno);
 			}
 			nread += readret;
 		}
@@ -613,6 +615,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 
 		/* Check if error */
 		if (selrtn == -1) {
+			save_errno = errno;
 			/* something is wrong. Maybe the socket is dead? */
 			if (fd == get_client_fd()) {
 				/* Try and give an error message saying
@@ -620,13 +623,13 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 				DEBUG(0,("read_socket_with_timeout: timeout "
 				"read for client %s. select error = %s.\n",
 				get_peer_addr(fd,addr,sizeof(addr)),
-				strerror(errno) ));
+				strerror(save_errno) ));
 			} else {
 				DEBUG(0,("read_socket_with_timeout: timeout "
 				"read. select error = %s.\n",
-				strerror(errno) ));
+				strerror(save_errno) ));
 			}
-			return map_nt_error_from_unix(errno);
+			return map_nt_error_from_unix(save_errno);
 		}
 
 		/* Did we timeout ? */
@@ -646,6 +649,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 		}
 
 		if (readret == -1) {
+			save_errno = errno;
 			/* the descriptor is probably dead */
 			if (fd == get_client_fd()) {
 				/* Try and give an error message
@@ -653,11 +657,11 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
 				DEBUG(0,("read_socket_with_timeout: timeout "
 					"read to client %s. read error = %s.\n",
 					get_peer_addr(fd,addr,sizeof(addr)),
-					strerror(errno) ));
+					strerror(save_errno) ));
 			} else {
 				DEBUG(0,("read_socket_with_timeout: timeout "
 					"read. read error = %s.\n",
-					strerror(errno) ));
+					strerror(save_errno) ));
 			}
 			return map_nt_error_from_unix(errno);
 		}
diff --git a/source3/smbd/notify_inotify.c b/source3/smbd/notify_inotify.c
index 26570a2..6159945 100644
--- a/source3/smbd/notify_inotify.c
+++ b/source3/smbd/notify_inotify.c
@@ -232,6 +232,7 @@ static void inotify_handler(struct event_context *ev, struct fd_event *fde,
 	int bufsize = 0;
 	struct inotify_event *e0, *e;
 	uint32_t prev_cookie=0;
+	NTSTATUS status;
 
 	/*
 	  we must use FIONREAD as we cannot predict the length of the
@@ -248,9 +249,14 @@ static void inotify_handler(struct event_context *ev, struct fd_event *fde,
 	e0 = e = (struct inotify_event *)TALLOC_SIZE(in, bufsize);
 	if (e == NULL) return;
 
-	if (sys_read(in->fd, e0, bufsize) != bufsize) {
-		DEBUG(0,("Failed to read all inotify data\n"));
+	status = read_data(in->fd, (char *)e0, bufsize);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0,("Failed to read all inotify data - %s\n",
+			nt_errstr(status)));
 		talloc_free(e0);
+		/* the inotify fd will now be out of sync,
+		 * can't keep reading data off it */
+		TALLOC_FREE(fde);
 		return;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list