r9126: Fix valgrind bug Volker found in interaction with new aio buffer
authorJeremy Allison <jra@samba.org>
Fri, 5 Aug 2005 17:10:10 +0000 (17:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:00:26 +0000 (11:00 -0500)
flipping and oplocks.
Jeremy.

source/smbd/oplock.c
source/smbd/process.c

index de1200398674bf6e5e70266c5f954cad3ce3841b..c0c9e989a9970abe5938e7c5bdc482adc7ec8077 100644 (file)
@@ -757,8 +757,9 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id,
 
        if((outbuf = NewOutBuffer(&saved_outbuf))==NULL) {
                DEBUG(0,("oplock_break: malloc fail for output buffer.\n"));
-               set_InBuffer(saved_inbuf);
+               /* Free must be done before set.. */
                free_InBuffer(inbuf);
+               set_InBuffer(saved_inbuf);
                return False;
        }
 
@@ -918,14 +919,15 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id,
        /* Restore the chain fnum. */
        file_chain_restore();
 
-       /* Restore the global In/Out buffers. */
-       set_InBuffer(saved_inbuf);
-       set_OutBuffer(saved_outbuf);
-
        /* Free the buffers we've been using to recurse. */
+       /* Free must be done before set.. */
        free_InBuffer(inbuf);
        free_OutBuffer(outbuf);
 
+       /* Restore the global In/Out buffers. */
+       set_InBuffer(saved_inbuf);
+       set_OutBuffer(saved_outbuf);
+
        /* We need this in case a readraw crossed on the wire. */
        if(global_oplock_break)
                global_oplock_break = False;
index 19add7e0951424609eed36608249c5f81aa7140a..1deb4da269699e61d31a5698ae2debcf9bcfc575 100644 (file)
@@ -1527,6 +1527,7 @@ char *get_InBuffer(void)
 void set_InBuffer(char *new_inbuf)
 {
        InBuffer = new_inbuf;
+       current_inbuf = InBuffer;
 }
 
 char *get_OutBuffer(void)
@@ -1547,6 +1548,9 @@ void set_OutBuffer(char *new_outbuf)
 void free_InBuffer(char *inbuf)
 {
        if (!aio_inbuffer_in_use(inbuf)) {
+               if (current_inbuf == inbuf) {
+                       current_inbuf = NULL;
+               }
                SAFE_FREE(inbuf);
        }
 }