[Wine-patches] server: Fix regression with locks on CIFS.
Alexander Morozov
amorozov на etersoft.ru
Пт Июл 17 19:19:15 MSD 2009
Патч надо приложить и к 1.0.10, и к eterhack.
----------- следующая часть -----------
From ff2e0e7798bdf8ec2b08851e46dcf2ce316271ec Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 17 Jul 2009 19:03:07 +0400
Subject: [PATCH] server: Fix regression with locks on CIFS.
---
include/wine/etersoft.h | 2 ++
server/fd.c | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/include/wine/etersoft.h b/include/wine/etersoft.h
index 18f50e4..95f8e1a 100644
--- a/include/wine/etersoft.h
+++ b/include/wine/etersoft.h
@@ -121,6 +121,8 @@ static int (*etersoft_sharing_open)(const char *name, int flags, int shared, mod
static int (*etersoft_sharing_close)(int unix_fd );
+static int (*etersoft_check_cifs)(void);
+
static int (*etersoft_sharing_pre)(int unix_fd, DWORD access, DWORD sharing, unsigned int * existing_access,
unsigned int * existing_sharing);
static void (*etersoft_sharing_post)(int unix_fd, DWORD access, unsigned int existing_access,
diff --git a/server/fd.c b/server/fd.c
index a89b6cb..0581c55 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1150,6 +1150,21 @@ 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 (fd->cifs && fd->access == FILE_GENERIC_READ && type == F_WRLCK)
+ {
+ /* We can't set WR lock on read only opened file */
+ TRACEL(stderr, "Try to set WR on r/o file. Check with GETLK\n");
+ fl.l_type = F_WRLCK;
+ /* WARNING! Some races between GETLK and SETLK can be! */
+ fcntl( fd->unix_fd, F_GETLK, &fl );
+ if (fl.l_type != F_UNLCK)
+ {
+ TRACEL(stderr,"Already locked. \n");
+ set_error( STATUS_FILE_LOCK_CONFLICT );
+ return 0;
+ }
+ 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;
@@ -1705,6 +1720,7 @@ struct fd *open_fd( const char *name, int flags, mode_t *mode, unsigned int acce
if (etersoft_initialize && !etersoft_sharing_pre) {
TRACE(stderr, "WINE на Etersoft: Network version is running\n");
LOADETER_FUNC(etersoft_sharing_open);
+ LOADETER_FUNC(etersoft_check_cifs);
LOADETER_FUNC(etersoft_sharing_pre);
LOADETER_FUNC(etersoft_sharing_post);
LOADETER_FUNC(etersoft_sharing_set_test_fd);
@@ -1751,7 +1767,8 @@ 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 (rw_mode != O_RDWR && inode_get_lock_fd( inode ) == -1)
+ if (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 );
--
1.6.3.3
Подробная информация о списке рассылки Wine-patches