Skip to content

Commit 7a0f8d9

Browse files
committed
Cherry-pick harbour commit harbour/core#388
* include/hbapifs.h * src/rdd/wacore.c * src/rtl/filebuf.c + Fixed locking mechanism for SMB related networks and Linux kernel >= 5.5 - Removed old HB_USE_BSDLOCKS implementation, now broken on Linux too Closes: harbour/core#388 issue: #338 PR: harbour/core#389
1 parent b9410d6 commit 7a0f8d9

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

include/hbapifs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ extern HB_EXPORT BOOL hb_fsCloseProcess( HB_FHANDLE fhProc, BOOL bGentle )
231231
# define HB_USE_SHARELOCKS
232232
# define HB_SHARELOCK_POS 0x7fffffffUL
233233
# define HB_SHARELOCK_SIZE 0x1UL
234-
# if defined( HB_USE_BSDLOCKS_OFF )
235-
# undef HB_USE_BSDLOCKS
236-
# elif ( defined( HB_OS_LINUX ) /*|| defined( HB_OS_BSD )*/ ) && \
237-
!defined( __WATCOMC__ ) && !defined( HB_USE_BSDLOCKS )
238-
/* At least FreeBSD 6.2 and Mac OS X deadlock using BSDLOCKS so I disabled them -- Ph. */
239-
# define HB_USE_BSDLOCKS
240-
# endif
241234
#endif
242235

243236
#define HB_MAX_DRIVE_LENGTH 10

source/rtl/filebuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static PHB_FILE s_fileExtOpen( const char * pFilename, const char * pDefExt,
442442
}
443443
if( pFile->uiLocks == 0 )
444444
{
445-
#if ! defined( HB_USE_SHARELOCKS ) || defined( HB_USE_BSDLOCKS )
445+
#if ! defined( HB_USE_SHARELOCKS )
446446
if( pFile->hFileRO != FS_ERROR )
447447
{
448448
hb_fsClose( pFile->hFileRO );
@@ -453,7 +453,7 @@ static PHB_FILE s_fileExtOpen( const char * pFilename, const char * pDefExt,
453453
{
454454
hb_fsClose( hFile );
455455
hFile = FS_ERROR;
456-
#if defined( HB_USE_SHARELOCKS ) && ! defined( HB_USE_BSDLOCKS )
456+
#if defined( HB_USE_SHARELOCKS )
457457
/* TOFIX: possible race condition */
458458
hb_fsLockLarge( hFile, HB_SHARELOCK_POS, HB_SHARELOCK_SIZE,
459459
FL_LOCK | FLX_SHARED );

source/rtl/filesys.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ extern int fdatasync( int fildes );
234234
#define INVALID_FILE_ATTRIBUTES ( ( DWORD ) -1 )
235235
#endif
236236
#endif
237-
#if defined( HB_USE_SHARELOCKS ) && defined( HB_USE_BSDLOCKS )
237+
#if defined( HB_USE_SHARELOCKS )
238238
#include <sys/file.h>
239239
#endif
240240

@@ -4208,18 +4208,6 @@ HB_FHANDLE hb_fsExtOpen( const char * pFilename, const char * pDefExt,
42084208
#if defined( HB_USE_SHARELOCKS )
42094209
if( hFile != FS_ERROR && uiExFlags & FXO_SHARELOCK )
42104210
{
4211-
#if defined( HB_USE_BSDLOCKS )
4212-
int iLock;
4213-
if( ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ ||
4214-
( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
4215-
iLock = LOCK_SH | LOCK_NB;
4216-
else
4217-
iLock = LOCK_EX | LOCK_NB;
4218-
hb_vmUnlock();
4219-
iLock = flock( hFile, iLock );
4220-
hb_vmLock();
4221-
if( iLock != 0 )
4222-
#else
42234211
USHORT uiLock;
42244212
if( ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ ||
42254213
( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
@@ -4228,7 +4216,6 @@ HB_FHANDLE hb_fsExtOpen( const char * pFilename, const char * pDefExt,
42284216
uiLock = FL_LOCK | FLX_EXCLUSIVE;
42294217

42304218
if( ! hb_fsLockLarge( hFile, HB_SHARELOCK_POS, HB_SHARELOCK_SIZE, uiLock ) )
4231-
#endif
42324219
{
42334220
hb_fsClose( hFile );
42344221
hFile = FS_ERROR;

0 commit comments

Comments
 (0)