Author: jra
Date: 2005-08-05 17:10:10 +0000 (Fri, 05 Aug 2005)
New Revision: 9126

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9126

Log:
Fix valgrind bug Volker found in interaction with new aio buffer
flipping and oplocks.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/oplock.c
   branches/SAMBA_3_0/source/smbd/process.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/oplock.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/oplock.c     2005-08-05 17:10:07 UTC (rev 
9125)
+++ branches/SAMBA_3_0/source/smbd/oplock.c     2005-08-05 17:10:10 UTC (rev 
9126)
@@ -757,8 +757,9 @@
 
        if((outbuf = NewOutBuffer(&saved_outbuf))==NULL) {
                DEBUG(0,("oplock_break: malloc fail for output buffer.\n"));
+               /* Free must be done before set.. */
+               free_InBuffer(inbuf);
                set_InBuffer(saved_inbuf);
-               free_InBuffer(inbuf);
                return False;
        }
 
@@ -918,14 +919,15 @@
        /* Restore the chain fnum. */
        file_chain_restore();
 
+       /* 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);
 
-       /* Free the buffers we've been using to recurse. */
-       free_InBuffer(inbuf);
-       free_OutBuffer(outbuf);
-
        /* We need this in case a readraw crossed on the wire. */
        if(global_oplock_break)
                global_oplock_break = False;

Modified: branches/SAMBA_3_0/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/process.c    2005-08-05 17:10:07 UTC (rev 
9125)
+++ branches/SAMBA_3_0/source/smbd/process.c    2005-08-05 17:10:10 UTC (rev 
9126)
@@ -1527,6 +1527,7 @@
 void set_InBuffer(char *new_inbuf)
 {
        InBuffer = new_inbuf;
+       current_inbuf = InBuffer;
 }
 
 char *get_OutBuffer(void)
@@ -1547,6 +1548,9 @@
 void free_InBuffer(char *inbuf)
 {
        if (!aio_inbuffer_in_use(inbuf)) {
+               if (current_inbuf == inbuf) {
+                       current_inbuf = NULL;
+               }
                SAFE_FREE(inbuf);
        }
 }

Reply via email to