Skip to content

Commit 11b8bd9

Browse files
Gianfranco Costamagnamarco
authored andcommitted
* 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: #388 issue: #338
1 parent 1b633cd commit 11b8bd9

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

ChangeLog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
* src/rtl/transfrm.c
1717
! fixed bug in "@S<n>" transformation when multibyte CDP is used
1818

19+
2025-08-12 14:45 UTC+0200 Gianfranco Costamagna (locutusofborg debian.org)
20+
* include/hbapifs.h
21+
* src/rdd/wacore.c
22+
* src/rtl/filebuf.c
23+
+ Fixed locking mechanism for SMB related networks and Linux kernel >= 5.5
24+
- Removed old HB_USE_BSDLOCKS implementation, now broken on Linux too
25+
1926
2025-07-19 19:44 UTC+0200 Aleksander Czajczynski (hb fki.pl)
2027
* contrib/hbhpdf/core.c
2128
+ HPDF_GetPageByIndex( hDoc, nIndex ) --> hPage / NIL

include/hbapifs.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,6 @@ extern HB_EXPORT int hb_fsCanWrite ( HB_FHANDLE hFileHandle, HB_MAXINT
227227
# define HB_USE_SHARELOCKS
228228
# define HB_SHARELOCK_POS 0x7fffffffUL
229229
# define HB_SHARELOCK_SIZE 0x1UL
230-
# if defined( HB_USE_BSDLOCKS_OFF )
231-
# undef HB_USE_BSDLOCKS
232-
# elif defined( HB_OS_LINUX ) && \
233-
! defined( __WATCOMC__ ) && ! defined( HB_USE_BSDLOCKS )
234-
/* default usage of BSD locks in *BSD systems for emulating
235-
* MS-DOS/Windows DENY_* flags has been disabled because tests
236-
* on FreeBSD 6.2 and macOS shows that this implementation
237-
* can create self deadlock when used simultaneously with
238-
* POSIX locks - thanks to Phil and Lorenzo for locating the
239-
* problem and tests [druzus]
240-
*/
241-
# define HB_USE_BSDLOCKS
242-
# endif
243230
#endif
244231

245232
#define HB_MAX_DRIVE_LENGTH 10

src/rtl/filebuf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ static PHB_FILE s_fileExtOpen( PHB_FILE_FUNCS pFuncs, const char * pszFileName,
491491
#if ! defined( HB_OS_UNIX )
492492
fResult = HB_TRUE;
493493
#else
494-
# if defined( HB_USE_SHARELOCKS ) && ! defined( HB_USE_BSDLOCKS )
494+
# if defined( HB_USE_SHARELOCKS )
495495
if( nExFlags & FXO_SHARELOCK )
496496
{
497497
if( iMode == FO_WRITE && fShared )
@@ -610,7 +610,7 @@ static PHB_FILE s_fileExtOpen( PHB_FILE_FUNCS pFuncs, const char * pszFileName,
610610

611611
if( pFile->uiLocks == 0 )
612612
{
613-
#if ! defined( HB_USE_SHARELOCKS ) || defined( HB_USE_BSDLOCKS )
613+
#if ! defined( HB_USE_SHARELOCKS )
614614
if( pFile->hFileRO != FS_ERROR )
615615
{
616616
hb_fsClose( pFile->hFileRO );
@@ -621,7 +621,7 @@ static PHB_FILE s_fileExtOpen( PHB_FILE_FUNCS pFuncs, const char * pszFileName,
621621
{
622622
hb_fsClose( hFile );
623623
hFile = FS_ERROR;
624-
#if defined( HB_USE_SHARELOCKS ) && ! defined( HB_USE_BSDLOCKS )
624+
#if defined( HB_USE_SHARELOCKS )
625625
/* FIXME: possible race condition */
626626
hb_fsLockLarge( pFile->hFile, HB_SHARELOCK_POS, HB_SHARELOCK_SIZE,
627627
FL_LOCK | FLX_SHARED );

src/rtl/filesys.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
#endif
192192
#endif
193193
#endif
194-
#if defined( HB_USE_SHARELOCKS ) && defined( HB_USE_BSDLOCKS )
194+
#if defined( HB_USE_SHARELOCKS )
195195
#include <sys/file.h>
196196
#endif
197197
#if defined( HB_OS_LINUX )
@@ -4729,18 +4729,6 @@ HB_FHANDLE hb_fsExtOpen( const char * pszFileName, const char * pDefExt,
47294729
#if defined( HB_USE_SHARELOCKS )
47304730
if( hFile != FS_ERROR && ( nExFlags & FXO_SHARELOCK ) != 0 )
47314731
{
4732-
#if defined( HB_USE_BSDLOCKS )
4733-
int iLock, iResult;
4734-
if( /* ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ || */
4735-
( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
4736-
iLock = LOCK_SH | LOCK_NB;
4737-
else
4738-
iLock = LOCK_EX | LOCK_NB;
4739-
hb_vmUnlock();
4740-
HB_FAILURE_RETRY( iResult, flock( hFile, iLock ) );
4741-
hb_vmLock();
4742-
if( iResult != 0 )
4743-
#else
47444732
HB_USHORT uiLock;
47454733
if( ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ ||
47464734
( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
@@ -4749,7 +4737,6 @@ HB_FHANDLE hb_fsExtOpen( const char * pszFileName, const char * pDefExt,
47494737
uiLock = FL_LOCK | FLX_EXCLUSIVE;
47504738

47514739
if( ! hb_fsLockLarge( hFile, HB_SHARELOCK_POS, HB_SHARELOCK_SIZE, uiLock ) )
4752-
#endif
47534740
{
47544741
hb_fsClose( hFile );
47554742
hFile = FS_ERROR;

0 commit comments

Comments
 (0)