[Wine-patches] [eterhack] eterbug #5798

Alexander Morozov amorozov на etersoft.ru
Вт Июн 14 21:09:53 MSD 2011


----------- следующая часть -----------
From 2bfbb873824c99d2f128f1dd6459fa291cffe64c Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 14 Jun 2011 21:06:36 +0400
Subject: [eterhack 1/2] Revert "Close a file descriptor used for locks when
 we need to ignore locks (eterbug #7350)."

This reverts commit 8fc237d5f3e4ac876bdff2265c5550c57b5816a6.
---
 dlls/ntdll/loader.c |    4 ----
 server/fd.c         |   10 ----------
 2 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 9d8276f..31a900d 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1914,7 +1914,6 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
     WINE_MODREF *main_exe;
     HANDLE handle = 0;
     NTSTATUS nts;
-    int fd;
 
     TRACE( "looking for %s in %s\n", debugstr_w(libname), debugstr_w(load_path) );
 
@@ -1939,9 +1938,6 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
             wine_server_call( req );
         }
         SERVER_END_REQ;
-
-        fd = server_remove_fd_from_cache( handle );
-        if (fd != -1) close( fd );
     }
 
     if (*pwm)  /* found already loaded module */
diff --git a/server/fd.c b/server/fd.c
index 64bec52..5d8b3a1 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2582,20 +2582,10 @@ DECL_HANDLER(add_fd_completion)
 DECL_HANDLER(ignore_locks)
 {
     struct fd *fd = get_handle_fd_obj( current->process, req->handle, 0 );
-    int lock_fd;
 
     if (fd)
     {
         fd->fs_locks = 0;
-        if (fd->inode)
-        {
-            lock_fd = inode_get_lock_fd( fd->inode );
-            if (lock_fd != -1)
-            {
-                inode_set_lock_fd( fd->inode, -1 );
-                close( lock_fd );
-            }
-        }
         release_object( fd );
     }
 }
-- 
1.7.4.5

----------- следующая часть -----------
From a3bc19a7610fcec22aff379db6f4c53241eff2d5 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 14 Jun 2011 19:18:53 +0400
Subject: [eterhack 2/2] server: Open file with O_RDWR instead of using
 special descriptor (eterbug #5798).

---
 server/fd.c |   70 +++++++++++-----------------------------------------------
 1 files changed, 14 insertions(+), 56 deletions(-)

diff --git a/server/fd.c b/server/fd.c
index 5d8b3a1..13cf266 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -284,7 +284,6 @@ struct inode
     struct list         open;       /* list of open file descriptors */
     struct list         locks;      /* list of file locks */
     struct list         closed;     /* list of file descriptors to close at destroy time */
-    int                 lock_fd;    /* unix file descriptor for locks */
 };
 
 static void inode_dump( struct object *obj, int verbose );
@@ -1091,11 +1090,6 @@ static void inode_close_pending( struct inode *inode, int keep_unlinks )
         }
         ptr = next;
     }
-    if (list_empty( &inode->open ) && inode->lock_fd != -1)
-    {
-        close( inode->lock_fd );
-        inode->lock_fd = -1;
-    }
 }
 
 static void inode_dump( struct object *obj, int verbose )
@@ -1133,8 +1127,6 @@ static void inode_destroy( struct object *obj )
         }
         free( fd );
     }
-    if (inode->lock_fd != -1)
-        close( inode->lock_fd );
     release_object( inode->device );
 }
 
@@ -1164,7 +1156,6 @@ static struct inode *get_inode( dev_t dev, ino_t ino, int unix_fd )
         list_init( &inode->open );
         list_init( &inode->locks );
         list_init( &inode->closed );
-        inode->lock_fd = -1;
         list_add_head( &device->inode_hash[hash], &inode->entry );
     }
     else release_object( device );
@@ -1195,18 +1186,6 @@ static void inode_add_closed_fd( struct inode *inode, struct closed_fd *fd )
     }
 }
 
-/* get fd which can be used for locks */
-static int inode_get_lock_fd( struct inode *inode )
-{
-    return inode->lock_fd;
-}
-
-/* set fd which can be used for locks */
-static void inode_set_lock_fd( struct inode *inode, int lock_fd )
-{
-    inode->lock_fd = lock_fd;
-}
-
 
 /****************************************************************/
 /* file lock functions */
@@ -1233,7 +1212,6 @@ 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 (;;)
@@ -1264,9 +1242,7 @@ static int set_unix_lock( struct fd *fd, file_pos_t start, file_pos_t end, int t
             }
             fl.l_type = F_RDLCK;
         }
-        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;
+        if (fcntl( fd->unix_fd, F_SETLK, &fl ) != -1) return 1;
 	/* perror("Etersoft warning (some error during lock):"); */
         switch(errno)
         {
@@ -1768,7 +1744,6 @@ static unsigned int check_sharing( struct fd *fd, unsigned int access, unsigned
     unsigned int existing_sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
     unsigned int existing_access = 0;
     struct list *ptr;
-    int lock_fd;
 
     fd->access = access;
     fd->sharing = sharing;
@@ -1784,20 +1759,9 @@ static unsigned int check_sharing( struct fd *fd, unsigned int access, unsigned
         }
     }
     /* Etersoft: Set existing modes from special lock region state, get cifs status */
-    if (fd->unix_fd != -1)
-    {
-        if (etersoft_sharing_set_test_fd)
-        {
-            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);
-    }
+    if (fd->unix_fd != -1 && etersoft_sharing_pre)
+        fd->cifs = etersoft_sharing_pre(fd->unix_fd, fd->access, fd->sharing,
+                                        &existing_access, &existing_sharing);
 
     if (((access & FILE_UNIX_READ_ACCESS) && !(existing_sharing & FILE_SHARE_READ)) ||
         ((access & FILE_UNIX_WRITE_ACCESS) && !(existing_sharing & FILE_SHARE_WRITE)) ||
@@ -1975,7 +1939,15 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
 
     /* Etersoft: Set existing modes from special lock region state */
     if (etersoft_sharing_open)
-        fd->unix_fd = etersoft_sharing_open(name, rw_mode | (flags & ~O_TRUNC) | O_NOCTTY, sharing, *mode );
+    {
+        fd->unix_fd = -1;
+        if (!etersoft_check_cifs || !etersoft_check_cifs())
+            fd->unix_fd = etersoft_sharing_open(name, O_RDWR | (flags & ~O_TRUNC) | O_NOCTTY, sharing, *mode );
+        if (fd->unix_fd == -1)
+            fd->unix_fd = etersoft_sharing_open(name, rw_mode | (flags & ~O_TRUNC) | O_NOCTTY, sharing, *mode );
+        else if (etersoft_sharing_set_test_fd)
+            etersoft_sharing_set_test_fd( fd->unix_fd );
+    }
     else
         fd->unix_fd = open(name, rw_mode | (flags & ~O_TRUNC) | O_NOCTTY, *mode );
     /* Can we detect cifs here?
@@ -2007,7 +1979,6 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
     if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
     {
         struct inode *inode = get_inode( st.st_dev, st.st_ino, fd->unix_fd );
-        int lock_fd;
 
         if (!inode)
         {
@@ -2021,14 +1992,6 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
         fd->cacheable = !inode->device->removable;
         list_add_head( &inode->open, &fd->inode_entry );
 
-        if (S_ISREG(st.st_mode) && rw_mode != O_RDWR &&
-            inode_get_lock_fd( inode ) == -1 &&
-            (!etersoft_check_cifs || !etersoft_check_cifs()))
-        {
-            lock_fd = open( name, O_RDWR );
-            inode_set_lock_fd( inode, lock_fd );
-        }
-
         /* check directory options */
         if ((options & FILE_DIRECTORY_FILE) && !S_ISDIR(st.st_mode))
         {
@@ -2477,12 +2440,7 @@ DECL_HANDLER(get_handle_fd)
 
     if ((fd = get_handle_fd_obj( current->process, req->handle, 0 )))
     {
-        int unix_fd = -1;
-
-        if (fd->inode)
-            unix_fd = inode_get_lock_fd( fd->inode );
-        if (unix_fd == -1)
-            unix_fd = get_unix_fd( fd );
+        int unix_fd = get_unix_fd( fd );
         if (unix_fd != -1)
         {
             reply->type = fd->fd_ops->get_fd_type( fd );
-- 
1.7.4.5



Подробная информация о списке рассылки Wine-patches