diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-08 19:21:04 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-08 19:21:04 +0000 |
commit | 6e0c276ec8b918165a19b3dfc86bc7bef6d1f706 (patch) | |
tree | fb8c41b2af435269dbe4f5019d121b6572ad07d5 /source3/smbd/open.c | |
parent | 519a6d5f0ed0d81cf739394c1c8c305f8ae43c87 (diff) | |
download | samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.tar.gz samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.tar.xz samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.zip |
Added back groupname map stuff removed by Andrew's "slash 'n' burn"
tactics :-). Protected by #ifdef until used.
Fixed bug in fd_attempt_close() where a pointer to potentially
free'd memory was returned. I hate that.
Added "blocking locks" as a per-share option for performance testing.
Changed is_mangled() so it will return true if called with a pathname
and any component of the pathname was mangled (it was already attempting
to do this, but not checking for a '/' as end-of-mangle).
This should be a better fix for the wierd stat cache bug Andrew identified.
Jeremy.
(This used to be commit 0de01f45980c7bc261248a9cead972a8d8cbd594)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r-- | source3/smbd/open.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index e6289b1cdbc..bd1ead69218 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -145,40 +145,37 @@ static void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr) fd support routines - attempt to close the file referenced by this fd. Decrements the ref_count and returns it. ****************************************************************************/ -int fd_attempt_close(file_fd_struct *fd_ptr) +uint16 fd_attempt_close(file_fd_struct *fd_ptr) { extern struct current_user current_user; + uint16 ret_ref = fd_ptr->ref_count; -#ifdef LARGE_SMB_INO_T DEBUG(3,("fd_attempt_close fd = %d, dev = %x, inode = %.0f, open_flags = %d, ref_count = %d.\n", fd_ptr->fd, (unsigned int)fd_ptr->dev, (double)fd_ptr->inode, fd_ptr->real_open_flags, fd_ptr->ref_count)); -#else /* LARGE_SMB_INO_T */ - DEBUG(3,("fd_attempt_close fd = %d, dev = %x, inode = %lx, open_flags = %d, ref_count = %d.\n", - fd_ptr->fd, (unsigned int)fd_ptr->dev, (unsigned long)fd_ptr->inode, - fd_ptr->real_open_flags, - fd_ptr->ref_count)); -#endif /* LARGE_SMB_INO_T */ - if(fd_ptr->ref_count > 0) { - fd_ptr->ref_count--; - if(fd_ptr->ref_count == 0) { - if(fd_ptr->fd != -1) - close(fd_ptr->fd); - if(fd_ptr->fd_readonly != -1) - close(fd_ptr->fd_readonly); - if(fd_ptr->fd_writeonly != -1) - close(fd_ptr->fd_writeonly); - /* - * Delete this fd_ptr. - */ - fd_ptr_free(fd_ptr); - } else { - fd_remove_from_uid_cache(fd_ptr, (uid_t)current_user.uid); - } - } - return fd_ptr->ref_count; + SMB_ASSERT(fd_ptr->ref_count != 0); + + fd_ptr->ref_count--; + ret_ref = fd_ptr->ref_count; + + if(fd_ptr->ref_count == 0) { + if(fd_ptr->fd != -1) + close(fd_ptr->fd); + if(fd_ptr->fd_readonly != -1) + close(fd_ptr->fd_readonly); + if(fd_ptr->fd_writeonly != -1) + close(fd_ptr->fd_writeonly); + /* + * Delete this fd_ptr. + */ + fd_ptr_free(fd_ptr); + } else { + fd_remove_from_uid_cache(fd_ptr, (uid_t)current_user.uid); + } + + return ret_ref; } /**************************************************************************** |