[Wine-patches] [eterhack] [eter-1.0.12] server: In case of CIFS unlock exactly that locks which were set.

Alexander Morozov amorozov на etersoft.ru
Вт Сен 27 16:30:10 MSD 2011


----------- следующая часть -----------
From aa2a8375a3737217b7d6b559b0d2386c815a0225 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 27 Sep 2011 16:18:13 +0400
Subject: [PATCH] server: In case of CIFS unlock exactly that locks which were
 set.

---
 server/fd.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/server/fd.c b/server/fd.c
index 43e8026..eaa0535 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1423,14 +1423,17 @@ static struct file_lock *add_lock( struct fd *fd, int shared, file_pos_t start,
 }
 
 /* remove an existing lock */
-static void remove_lock( struct file_lock *lock, int remove_unix )
+static void remove_lock( struct file_lock *lock )
 {
     struct inode *inode = lock->fd->inode;
 
     list_remove( &lock->fd_entry );
     list_remove( &lock->inode_entry );
     list_remove( &lock->proc_entry );
-    if (remove_unix) remove_unix_locks( lock->fd, lock->start, lock->end );
+    if (lock->fd->cifs)
+        set_unix_lock( lock->fd, lock->start, lock->end, F_UNLCK );
+    else
+        remove_unix_locks( lock->fd, lock->start, lock->end );
     if (list_empty( &inode->locks )) inode_close_pending( inode, 1 );
     lock->process = NULL;
     wake_up( &lock->obj, 0 );
@@ -1445,24 +1448,20 @@ void remove_process_locks( struct process *process )
     while ((ptr = list_head( &process->locks )))
     {
         struct file_lock *lock = LIST_ENTRY( ptr, struct file_lock, proc_entry );
-        remove_lock( lock, 1 );  /* this removes it from the list */
+        remove_lock( lock );  /* this removes it from the list */
     }
 }
 
 /* remove all locks on a given fd */
 static void remove_fd_locks( struct fd *fd )
 {
-    file_pos_t start = FILE_POS_T_MAX, end = 0;
     struct list *ptr;
 
     while ((ptr = list_head( &fd->locks )))
     {
         struct file_lock *lock = LIST_ENTRY( ptr, struct file_lock, fd_entry );
-        if (lock->start < start) start = lock->start;
-        if (!lock->end || lock->end > end) end = lock->end - 1;
-        remove_lock( lock, 0 );
+        remove_lock( lock );
     }
-    if (start < end) remove_unix_locks( fd, start, end + 1 );
 }
 
 /* add a lock on an fd */
@@ -1523,7 +1522,7 @@ void unlock_fd( struct fd *fd, file_pos_t start, file_pos_t count )
         struct file_lock *lock = LIST_ENTRY( ptr, struct file_lock, fd_entry );
         if ((lock->start == start) && (lock->end == end))
         {
-            remove_lock( lock, 1 );
+            remove_lock( lock );
             return;
         }
     }
-- 
1.7.6.1



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