diff options
author | Jeremy Allison <jra@samba.org> | 2005-08-05 17:10:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:00:26 -0500 |
commit | a18c5ff3eada93e46da3f7cbd326b8dceb72e147 (patch) | |
tree | eef1e1f6069467894deb6b1a085310c1234f5e40 /source/smbd | |
parent | e9427912a763b0e4bb47724f835b91c2252105e8 (diff) | |
download | samba-a18c5ff3eada93e46da3f7cbd326b8dceb72e147.tar.gz samba-a18c5ff3eada93e46da3f7cbd326b8dceb72e147.tar.xz samba-a18c5ff3eada93e46da3f7cbd326b8dceb72e147.zip |
r9126: Fix valgrind bug Volker found in interaction with new aio buffer
flipping and oplocks.
Jeremy.
Diffstat (limited to 'source/smbd')
-rw-r--r-- | source/smbd/oplock.c | 12 | ||||
-rw-r--r-- | source/smbd/process.c | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c index de120039867..c0c9e989a99 100644 --- a/source/smbd/oplock.c +++ b/source/smbd/oplock.c @@ -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; diff --git a/source/smbd/process.c b/source/smbd/process.c index 19add7e0951..1deb4da2696 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -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); } } |