From f8e5696bd6d839dee9c98640519efe2f2512df99 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Apr 2000 01:01:07 +0000 Subject: Added optimization where we are single opener (don't free POSIX locks). Jeremy. (This used to be commit a2deb91128d59ad04f4ec858ffe4e30f2afb0edd) --- source3/locking/locking.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source3/locking/locking.c') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index d69ab18006..62304076af 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -772,6 +772,26 @@ void locking_close_file(files_struct *fsp) struct unlock_list *ul = NULL; int eclass; uint32 ecode; + struct pending_closes *pc; + + /* + * Optimization for the common case where we are the only + * opener of a file. If all fd entries are our own, we don't + * need to explicitly release all the locks via the POSIX functions, + * we can just release all the brl locks, as in the no POSIX locking case. + */ + + if ((pc = find_pending_close_entry(fsp->dev, fsp->inode)) != NULL) { + + if (pc->fd_array_size == 1 && pc->fd_array[0] == fsp->fd ) { + /* + * Just release all the brl locks, no need to release individually. + */ + + brl_close(fsp->dev, fsp->inode, pid, fsp->conn->cnum, fsp->fnum); + return; + } + } if ((ul_ctx = talloc_init()) == NULL) { DEBUG(0,("locking_close_file: unable to init talloc context.\n")); @@ -802,7 +822,7 @@ void locking_close_file(files_struct *fsp) } else { /* - * Just release all the tdb locks, no need to release individually. + * Just release all the brl locks, no need to release individually. */ brl_close(fsp->dev, fsp->inode, pid, fsp->conn->cnum, fsp->fnum); -- cgit