[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-3406-g077e0ed

Volker Lendecke vlendec at samba.org
Wed Jan 28 15:20:13 GMT 2009


The branch, v3-2-test has been updated
       via  077e0ed31315242c571ccd9e9579f53aac0dbbc7 (commit)
       via  8e7d0cf27cf9eb18be497d13bd0dbbe1d76b97a0 (commit)
      from  a8eb8de94f5bfe4de000c5e85a43469af555a717 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 077e0ed31315242c571ccd9e9579f53aac0dbbc7
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jan 28 10:35:35 2009 +0100

    Avoid valgrind errors
    
    In event handlers, we might destroy other events that are pending in the lists.
    We can only run one event safely per select call.
    
    Yes, I've seen these valgrind errors :-)
    
    Jeremy, with ccdd921e61 you had checked in the change to run multiple events.
    Do you remember why it was necessary and could not be solved in a different
    way?
    
    Volker

commit 8e7d0cf27cf9eb18be497d13bd0dbbe1d76b97a0
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 27 19:41:34 2009 +0100

    Fix a valgrind error when the socket dies
    
    Don't reference anything that might have been deleted in the async_req_error
    call.

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

Summary of changes:
 source/lib/events.c       |   38 ++++++++++----------------------------
 source/libsmb/async_smb.c |    5 +++--
 2 files changed, 13 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/events.c b/source/lib/events.c
index 229e7e2..9d809fb 100644
--- a/source/lib/events.c
+++ b/source/lib/events.c
@@ -245,22 +245,13 @@ bool events_pending(struct event_context *event_ctx)
 bool run_events(struct event_context *event_ctx,
 		int selrtn, fd_set *read_fds, fd_set *write_fds)
 {
-	bool fired = False;
-	struct fd_event *fde, *next;
-
-	/* Run all events that are pending, not just one (as we
-	   did previously. */
+	struct fd_event *fde;
+	struct timeval now;
 
-	while (event_ctx->timed_events) {
-		struct timeval now;
-		GetTimeOfDay(&now);
+	GetTimeOfDay(&now);
 
-		if (timeval_compare(
-			    &now, &event_ctx->timed_events->when) < 0) {
-			/* Nothing to do yet */
-			DEBUG(11, ("run_events: Nothing to do\n"));
-			break;
-		}
+	if ((event_ctx->timed_events != NULL)
+	    && (timeval_compare(&now, &event_ctx->timed_events->when) >= 0)) {
 
 		DEBUG(10, ("Running event \"%s\" %lx\n",
 			   event_ctx->timed_events->event_name,
@@ -271,38 +262,29 @@ bool run_events(struct event_context *event_ctx,
 			event_ctx->timed_events, &now,
 			event_ctx->timed_events->private_data);
 
-		fired = True;
-	}
-
-	if (fired) {
-		/*
-		 * We might have changed the socket status during the timed
-		 * events, return to run select again.
-		 */
-		return True;
+		return true;
 	}
 
 	if (selrtn == 0) {
 		/*
 		 * No fd ready
 		 */
-		return fired;
+		return false;
 	}
 
-	for (fde = event_ctx->fd_events; fde; fde = next) {
+	for (fde = event_ctx->fd_events; fde; fde = fde->next) {
 		uint16 flags = 0;
 
-		next = fde->next;
 		if (FD_ISSET(fde->fd, read_fds)) flags |= EVENT_FD_READ;
 		if (FD_ISSET(fde->fd, write_fds)) flags |= EVENT_FD_WRITE;
 
 		if (flags) {
 			fde->handler(event_ctx, fde, flags, fde->private_data);
-			fired = True;
+			return true;
 		}
 	}
 
-	return fired;
+	return false;
 }
 
 
diff --git a/source/libsmb/async_smb.c b/source/libsmb/async_smb.c
index 9346264..a031516 100644
--- a/source/libsmb/async_smb.c
+++ b/source/libsmb/async_smb.c
@@ -318,7 +318,7 @@ static void cli_state_handler(struct event_context *event_ctx,
 			      struct fd_event *event, uint16 flags, void *p)
 {
 	struct cli_state *cli = (struct cli_state *)p;
-	struct cli_request *req;
+	struct cli_request *req, *next;
 	NTSTATUS status;
 
 	DEBUG(11, ("cli_state_handler called with flags %d\n", flags));
@@ -421,7 +421,8 @@ static void cli_state_handler(struct event_context *event_ctx,
 	return;
 
  sock_error:
-	for (req = cli->outstanding_requests; req; req = req->next) {
+	for (req = cli->outstanding_requests; req; req = next) {
+		next = req;
 		async_req_error(req->async, status);
 	}
 	TALLOC_FREE(cli->fd_event);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list