2016-01-15 16:02 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/hbapifs.h
  * src/common/hbfsapi.c
    + added automatic file handle table resizing to hb_fsOS2DosOpenL()
    + added new C function: hb_fsOS2DosOpen() which is wrapper to DosOpen()
      with automatic file handle table resizing.
      Please remember that unlike hb_fsOS2DosOpenL() this function is
      pure wrapper to DosOpen() so it does not make file name conversions
      and does not set hb_fsError().

  * src/rtl/filesys.c
  * src/rtl/hbcom.c
  * src/rtl/hbproces.c
    * use hb_fsOS2DosOpen() instead of DosOpen()

  * src/vm/cmdarg.c
    * set the initial size of file handle table to 256 in OS2 OpenWatcom
      builds if user does not set it explicitly by //F:<n> switch

  * config/global.mk
    - removed set HARBOUR=F:100 - it's not necessary with automatic FHT
      resizing

  ; Please test it in real OS2 environment
This commit is contained in:
Przemysław Czerpak
2016-01-15 16:02:45 +01:00
parent cef75de547
commit 682d8e32e3
8 changed files with 132 additions and 33 deletions

View File

@@ -10,6 +10,31 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2016-01-15 16:02 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbapifs.h
* src/common/hbfsapi.c
+ added automatic file handle table resizing to hb_fsOS2DosOpenL()
+ added new C function: hb_fsOS2DosOpen() which is wrapper to DosOpen()
with automatic file handle table resizing.
Please remember that unlike hb_fsOS2DosOpenL() this function is
pure wrapper to DosOpen() so it does not make file name conversions
and does not set hb_fsError().
* src/rtl/filesys.c
* src/rtl/hbcom.c
* src/rtl/hbproces.c
* use hb_fsOS2DosOpen() instead of DosOpen()
* src/vm/cmdarg.c
* set the initial size of file handle table to 256 in OS2 OpenWatcom
builds if user does not set it explicitly by //F:<n> switch
* config/global.mk
- removed set HARBOUR=F:100 - it's not necessary with automatic FHT
resizing
; Please test it in real OS2 environment
2016-01-15 15:20 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
* *
% remove brandings and homepage from copyright header. Pass 3 - manual.

View File

@@ -2042,11 +2042,6 @@ export HARBOURCMD :=
export CLIPPER :=
export CLIPPERCMD :=
# in OS2 increase maximum number of file handle from 20 to 100 for -j<n> build switch
ifeq ($(HB_HOST_PLAT),os2)
export HARBOUR := F:100
endif
# relevant only on non-*nix hosts where --print-directory is on by default
ifeq ($(findstring w,$(MAKEFLAGS)),)
MKFLAGS := --no-print-directory

View File

@@ -301,6 +301,10 @@ extern HB_EXPORT HB_WCHAR * hb_fsNameConvU16( const char * pszFileName );
#endif
#if defined( HB_OS_OS2 )
extern HB_EXPORT HB_BOOL hb_isWSeB( void );
extern HB_EXPORT HB_ULONG hb_fsOS2DosOpen( const char * pszFileName,
HB_FHANDLE * pHFile, HB_ULONG * pulAction,
HB_ULONG nInitSize, HB_ULONG ulAttribute,
HB_ULONG fsOpenFlags, HB_ULONG fsOpenMode );
extern HB_EXPORT HB_ULONG hb_fsOS2DosOpenL( const char * pszFileName,
HB_FHANDLE * pHFile, HB_ULONG * pulAction,
HB_FOFFSET nInitSize, HB_ULONG ulAttribute,

View File

@@ -351,29 +351,82 @@ HB_BOOL hb_isWSeB( void )
return s_iWSeB;
}
HB_ULONG hb_fsOS2DosOpen( const char * pszFileName,
HB_FHANDLE * pHFile, HB_ULONG * pulAction,
HB_ULONG nInitSize, HB_ULONG ulAttribute,
HB_ULONG fsOpenFlags, HB_ULONG fsOpenMode )
{
ULONG cbMaxFH = 20;
HFILE hFile = ( HFILE ) -1;
APIRET ret;
for( ;; )
{
ret = DosOpen( ( PSZ ) pszFileName, &hFile, pulAction, nInitSize,
ulAttribute, fsOpenFlags, fsOpenMode, NULL );
if( ret == ERROR_TOO_MANY_OPEN_FILES )
{
LONG cbReqCount = 64;
ULONG cbCurMaxFH = 0;
ret = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH );
if( ret == NO_ERROR && cbCurMaxFH > cbMaxFH )
{
cbMaxFH = cbCurMaxFH;
continue;
}
ret = ERROR_TOO_MANY_OPEN_FILES;
}
break;
}
/* Hack to make error reporting more DOS compatible, anyhow I'm
not sure it's good idea to have it [druzus] */
if( ret == ERROR_OPEN_FAILED )
ret = ERROR_FILE_NOT_FOUND;
*pHFile = ret == NO_ERROR ? ( HB_FHANDLE ) hFile : FS_ERROR;
return ret;
}
HB_ULONG hb_fsOS2DosOpenL( const char * pszFileName,
HB_FHANDLE * pHFile, HB_ULONG * pulAction,
HB_FOFFSET nInitSize, HB_ULONG ulAttribute,
HB_ULONG fsOpenFlags, HB_ULONG fsOpenMode )
{
ULONG cbMaxFH = 20;
char * pszFree;
HFILE hFile = ( HFILE ) -1;
APIRET ret;
pszFileName = hb_fsNameConv( pszFileName, &pszFree );
if( hb_isWSeB() )
/* if other process open file using DosOpen() then it will block
long file support for us, we can block other processes against
using DosOpen() by setting OPEN_SHARE_DENYLEGACY in fsOpenMode.
Is it good idea? [druzus] */
ret = s_DosOpenL( ( PSZ ) pszFileName, &hFile, pulAction,
( LONGLONG ) nInitSize, ulAttribute,
for( ;; )
{
if( hb_isWSeB() )
/* if other process open file using DosOpen() then it will block
long file support for us, we can block other processes against
using DosOpen() by setting OPEN_SHARE_DENYLEGACY in fsOpenMode.
Is it good idea? [druzus] */
ret = s_DosOpenL( ( PSZ ) pszFileName, &hFile, pulAction,
( LONGLONG ) nInitSize, ulAttribute,
fsOpenFlags, fsOpenMode, NULL );
else
ret = DosOpen( ( PSZ ) pszFileName, &hFile, pulAction,
( ULONG ) nInitSize, ulAttribute,
fsOpenFlags, fsOpenMode, NULL );
else
ret = DosOpen( ( PSZ ) pszFileName, &hFile, pulAction,
( ULONG ) nInitSize, ulAttribute,
fsOpenFlags, fsOpenMode, NULL );
if( ret == ERROR_TOO_MANY_OPEN_FILES )
{
LONG cbReqCount = 64;
ULONG cbCurMaxFH = 0;
ret = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH );
if( ret == NO_ERROR && cbCurMaxFH > cbMaxFH )
{
cbMaxFH = cbCurMaxFH;
continue;
}
ret = ERROR_TOO_MANY_OPEN_FILES;
}
break;
}
/* Hack to make error reporting more DOS compatible, anyhow I'm
not sure it's good idea to have it [druzus] */
if( ret == ERROR_OPEN_FAILED )

View File

@@ -914,13 +914,17 @@ HB_BOOL hb_fsPipeCreate( HB_FHANDLE hPipe[ 2 ] )
{
/* open the write end of then named pipe */
ULONG ulAction = 0;
ret = DosOpen( ( PSZ ) szPipeName, &hPipeWr, &ulAction, 0,
FILE_NORMAL,
OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_FAIL_ON_ERROR,
NULL );
HB_FHANDLE hFile;
ret = hb_fsOS2DosOpen( szPipeName, &hFile, &ulAction, 0,
FILE_NORMAL,
OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_FAIL_ON_ERROR );
if( ret == NO_ERROR )
{
hPipeWr = ( HFILE ) hFile;
break;
}
}
DosClose( hPipeRd );
}

View File

@@ -3060,19 +3060,23 @@ int hb_comOpen( int iPort )
char buffer[ HB_COM_DEV_NAME_MAX ];
const char * pszName = hb_comGetName( pCom, buffer, sizeof( buffer ) );
ULONG ulAction = 0;
HB_FHANDLE hFile;
hb_vmUnlock();
rc = DosOpen( ( PSZ ) pszName,
&pCom->hFile,
&ulAction,
0L,
FILE_NORMAL,
OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE,
0L );
rc = hb_fsOS2DosOpen( pszName,
&hFile,
&ulAction,
0L,
FILE_NORMAL,
OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE );
if( rc == NO_ERROR )
{
pCom->hFile = ( HFILE ) hFile;
pCom->status |= HB_COM_OPEN;
}
hb_comSetOsError( pCom, rc );

View File

@@ -580,9 +580,15 @@ HB_FHANDLE hb_fsProcessOpen( const char * pszFileName,
PHB_GT pGT;
if( fDetach && ( ! phStdin || ! phStdout || ! phStderr ) )
ret = DosOpen( ( PCSZ ) "NUL:", &hNull, &ulState, 0,
FILE_NORMAL, OPEN_ACCESS_READWRITE,
OPEN_ACTION_OPEN_IF_EXISTS, NULL );
{
HB_FHANDLE hFile;
ret = hb_fsOS2DosOpen( "NUL:", &hFile, &ulState, 0,
FILE_NORMAL, OPEN_ACCESS_READWRITE,
OPEN_ACTION_OPEN_IF_EXISTS );
if( ret == NO_ERROR )
hNull = ( HFILE ) hFile;
}
if( ret == NO_ERROR && phStdin != NULL )
{

View File

@@ -862,6 +862,14 @@ void hb_cmdargProcess( void )
#endif
#endif
}
else if( iHandles < 0 )
{
#if defined( __WATCOMC__ )
#if defined( HB_OS_OS2 )
DosSetMaxFH( 256 );
#endif
#endif
}
}
/* Source repository revision number */