[Wine-patches] [try 2] [eterhack 2/2] server: Do not open second file descriptor for locks if file is already opened with O_RDWR.
Alexander Morozov
amorozov на etersoft.ru
Пт Июл 10 17:32:50 MSD 2009
----------- следующая часть -----------
From e17ae9fbd9f22308eb9527e588b6a710fb7f1a2e Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 10 Jul 2009 17:23:44 +0400
Subject: [eterhack 2/2] server: Do not open second file descriptor for locks if file is already opened with O_RDWR.
---
server/fd.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/server/fd.c b/server/fd.c
index 16f3eeb..a89b6cb 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1134,6 +1134,7 @@ static int file_lock_signaled( struct object *obj, struct thread *thread )
static int set_unix_lock( struct fd *fd, file_pos_t start, file_pos_t end, int type )
{
struct flock fl;
+ int lock_fd;
if (!fd->fs_locks) return 1; /* no fs locks possible for this fd */
for (;;)
@@ -1149,7 +1150,9 @@ static int set_unix_lock( struct fd *fd, file_pos_t start, file_pos_t end, int t
if (!fl.l_len) {
TRACEL(stderr, "LEN is NULL!!!!!!!!!!");
}
- if (fcntl( inode_get_lock_fd( fd->inode ), F_SETLK, &fl ) != -1) return 1;
+ lock_fd = inode_get_lock_fd( fd->inode );
+ if (lock_fd == -1) lock_fd = fd->unix_fd;
+ if (fcntl( lock_fd, F_SETLK, &fl ) != -1) return 1;
/* perror("Etersoft warning (some error during lock):"); */
switch(errno)
{
@@ -1602,6 +1605,7 @@ static int check_sharing( struct fd *fd, unsigned int access, unsigned int shari
unsigned int existing_sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
unsigned int existing_access = 0;
struct list *ptr;
+ int lock_fd;
/* if access mode is 0, sharing mode is ignored */
if (!access) sharing = existing_sharing;
@@ -1619,7 +1623,13 @@ static int check_sharing( struct fd *fd, unsigned int access, unsigned int shari
}
/* Etersoft: Set existing modes from special lock region state, get cifs status */
if (etersoft_sharing_set_test_fd)
- etersoft_sharing_set_test_fd( inode_get_lock_fd( fd->inode ) );
+ {
+ lock_fd = inode_get_lock_fd( fd->inode );
+ if (lock_fd == -1 && (access & FILE_UNIX_READ_ACCESS) &&
+ (access & FILE_UNIX_WRITE_ACCESS))
+ lock_fd = fd->unix_fd;
+ etersoft_sharing_set_test_fd( lock_fd );
+ }
if (etersoft_sharing_pre)
fd->cifs = etersoft_sharing_pre(fd->unix_fd, fd->access, fd->sharing,
&existing_access, &existing_sharing);
@@ -1741,7 +1751,7 @@ struct fd *open_fd( const char *name, int flags, mode_t *mode, unsigned int acce
fd->closed = closed_fd;
list_add_head( &inode->open, &fd->inode_entry );
- if (inode_get_lock_fd( inode ) == -1)
+ if (rw_mode != O_RDWR && inode_get_lock_fd( inode ) == -1)
{
lock_fd = open( name, O_RDWR );
inode_set_lock_fd( inode, lock_fd );
--
1.6.3.3
Подробная информация о списке рассылки Wine-patches