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

Volker Lendecke vlendec at samba.org
Wed Jan 28 15:21:34 GMT 2009


The branch, v3-3-test has been updated
       via  910cbc5d6e932fa8ed0066d407a40195b6629a37 (commit)
       via  3e9c89e81b2915ba1a2aac7b8d72a780f7f9b80e (commit)
      from  a8a8dde5ac2b0c0b33e49af685650440469b287f (commit)

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


- Log -----------------------------------------------------------------
commit 910cbc5d6e932fa8ed0066d407a40195b6629a37
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 3e9c89e81b2915ba1a2aac7b8d72a780f7f9b80e
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 0dd8727..cd20ceb 100644
--- a/source/lib/events.c
+++ b/source/lib/events.c
@@ -218,22 +218,13 @@ bool event_add_to_select_args(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,
@@ -244,38 +235,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->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 935ae47..a1896e1 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