r23589: Ensure we will always release any timeout handler
authorJeremy Allison <jra@samba.org>
Fri, 22 Jun 2007 17:19:08 +0000 (17:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:33 +0000 (12:23 -0500)
on fsp close or removal of oplock. Mulitple removals
are safe.
Jeremy.

source/smbd/files.c
source/smbd/oplock.c

index 590916011b0396ba435d9888324a5399333c41a1..9994b50d15ae3c41f2ceaffa337a48af72f9554e 100644 (file)
@@ -439,6 +439,9 @@ void file_free(files_struct *fsp)
                TALLOC_FREE(fsp->notify);
        }
 
+       /* Ensure this event will never fire. */
+       TALLOC_FREE(fsp->oplock_timeout);
+
        bitmap_clear(file_bmap, fsp->fnum - FILE_HANDLE_OFFSET);
        files_used--;
 
index ddb05d8b922e15cf6f27e86eb5b486ab372b3e8a..39fc847d6ffd4b41450c66289bf08da6fc20c4c9 100644 (file)
@@ -152,6 +152,8 @@ void release_file_oplock(files_struct *fsp)
        fsp->sent_oplock_break = NO_BREAK_SENT;
        
        flush_write_cache(fsp, OPLOCK_RELEASE_FLUSH);
+
+       TALLOC_FREE(fsp->oplock_timeout);
 }
 
 /****************************************************************************
@@ -341,12 +343,8 @@ static void oplock_timeout_handler(struct event_context *ctx,
 {
        files_struct *fsp = (files_struct *)private_data;
 
-       /* Ensure we always remove this event. */
-       if (fsp->oplock_timeout != NULL) {
-               /* Remove the timed event handler. */
-               TALLOC_FREE(fsp->oplock_timeout);
-               fsp->oplock_timeout = NULL;
-       }
+       /* Remove the timed event handler. */
+       TALLOC_FREE(fsp->oplock_timeout);
        DEBUG(0, ("Oplock break failed for file %s -- replying anyway\n", fsp->fsp_name));
        global_client_failed_oplock_break = True;
        remove_oplock(fsp);