2016-04-07 18:34 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/common/hbprintf.c
* pacified warning
* src/rtl/filesys.c
! return -1 instead of from hb_fsPipeIsData() when poll() detects
error or end of stream - 0 should indicate timeout only.
* src/rtl/hbcom.c
! fixed bad typo which blocked hb_comSend() in *nixes
using select() instead of poll()
* src/rtl/filesys.c
* src/rtl/hbcom.c
* src/rtl/hbproces.c
* src/rtl/hbsocket.c
; updated #if/#else/#endif comments
This commit is contained in:
@@ -10,6 +10,24 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2016-04-07 18:34 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/common/hbprintf.c
|
||||
* pacified warning
|
||||
|
||||
* src/rtl/filesys.c
|
||||
! return -1 instead of from hb_fsPipeIsData() when poll() detects
|
||||
error or end of stream - 0 should indicate timeout only.
|
||||
|
||||
* src/rtl/hbcom.c
|
||||
! fixed bad typo which blocked hb_comSend() in *nixes
|
||||
using select() instead of poll()
|
||||
|
||||
* src/rtl/filesys.c
|
||||
* src/rtl/hbcom.c
|
||||
* src/rtl/hbproces.c
|
||||
* src/rtl/hbsocket.c
|
||||
; updated #if/#else/#endif comments
|
||||
|
||||
2016-04-06 15:49 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/common/hbprintf.c
|
||||
* pacified warnings
|
||||
|
||||
@@ -1227,8 +1227,8 @@ int hb_vsnprintf( char * buffer, size_t bufsize, const char * format, va_list ap
|
||||
{
|
||||
double d = va_arg_n( args, _x_double, param );
|
||||
HB_NUMTYPE( value, d );
|
||||
argval.value.as_x_long_dbl =
|
||||
( value & ( _HB_NUM_NAN | _HB_NUM_PINF | _HB_NUM_NINF ) ) == 0 ? d : 0;
|
||||
argval.value.as_x_long_dbl = ( _x_long_dbl )
|
||||
( ( value & ( _HB_NUM_NAN | _HB_NUM_PINF | _HB_NUM_NINF ) ) == 0 ? d : 0 );
|
||||
}
|
||||
if( value & _HB_NUM_NAN )
|
||||
size = put_str( buffer, bufsize, size,
|
||||
|
||||
@@ -1154,7 +1154,8 @@ HB_SIZE hb_fsPipeIsData( HB_FHANDLE hPipeHandle, HB_SIZE nBufferSize,
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
int tout = nTimeOut < 0 || nTimeOut > 1000 ? 1000 : ( int ) nTimeOut;
|
||||
HB_BOOL fLast = nTimeOut >= 0 && nTimeOut <= 1000;
|
||||
int tout = fLast ? ( int ) nTimeOut : 1000;
|
||||
iResult = poll( &fds, 1, tout );
|
||||
hb_fsSetIOError( iResult >= 0, 0 );
|
||||
if( iResult > 0 && ( fds.revents & POLLIN ) == 0 )
|
||||
@@ -1166,9 +1167,12 @@ HB_SIZE hb_fsPipeIsData( HB_FHANDLE hPipeHandle, HB_SIZE nBufferSize,
|
||||
}
|
||||
iResult = 0;
|
||||
}
|
||||
if( ( ( iResult == 0 && ( nTimeOut < 0 || nTimeOut > 1000 ) ) ||
|
||||
( iResult == -1 && nTimeOut != 0 && hb_fsOsError() == ( HB_ERRCODE ) EINTR ) ) &&
|
||||
hb_vmRequestQuery() == 0 )
|
||||
else if( iResult == -1 && hb_fsOsError() == ( HB_ERRCODE ) EINTR )
|
||||
{
|
||||
iResult = 0;
|
||||
fLast = HB_FALSE;
|
||||
}
|
||||
if( iResult == 0 && ! fLast && hb_vmRequestQuery() == 0 )
|
||||
{
|
||||
if( nTimeOut < 0 )
|
||||
continue;
|
||||
@@ -1185,7 +1189,7 @@ HB_SIZE hb_fsPipeIsData( HB_FHANDLE hPipeHandle, HB_SIZE nBufferSize,
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv;
|
||||
fd_set rfds;
|
||||
# if ! defined( HB_HAS_SELECT_TIMER )
|
||||
@@ -1233,10 +1237,12 @@ HB_SIZE hb_fsPipeIsData( HB_FHANDLE hPipeHandle, HB_SIZE nBufferSize,
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
|
||||
if( iResult > 0 )
|
||||
nToRead = nBufferSize;
|
||||
else if( iResult < 0 )
|
||||
nToRead = ( HB_SIZE ) FS_ERROR;
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -1397,7 +1403,9 @@ HB_SIZE hb_fsPipeWrite( HB_FHANDLE hPipeHandle, const void * buffer, HB_SIZE nSi
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
int tout = nTimeOut < 0 || nTimeOut > 1000 ? 1000 : ( int ) nTimeOut;
|
||||
HB_BOOL fLast = nTimeOut >= 0 && nTimeOut <= 1000;
|
||||
int tout = fLast ? ( int ) nTimeOut : 1000;
|
||||
|
||||
iResult = poll( &fds, 1, tout );
|
||||
hb_fsSetIOError( iResult >= 0, 0 );
|
||||
if( iResult > 0 && ( fds.revents & POLLOUT ) == 0 )
|
||||
@@ -1409,9 +1417,12 @@ HB_SIZE hb_fsPipeWrite( HB_FHANDLE hPipeHandle, const void * buffer, HB_SIZE nSi
|
||||
}
|
||||
iResult = 0;
|
||||
}
|
||||
if( ( ( iResult == 0 && ( nTimeOut < 0 || nTimeOut > 1000 ) ) ||
|
||||
( iResult == -1 && nTimeOut != 0 && hb_fsOsError() == ( HB_ERRCODE ) EINTR ) ) &&
|
||||
hb_vmRequestQuery() == 0 )
|
||||
else if( iResult == -1 && hb_fsOsError() == ( HB_ERRCODE ) EINTR )
|
||||
{
|
||||
iResult = 0;
|
||||
fLast = HB_FALSE;
|
||||
}
|
||||
if( iResult == 0 && ! fLast && hb_vmRequestQuery() == 0 )
|
||||
{
|
||||
if( nTimeOut < 0 )
|
||||
continue;
|
||||
@@ -1428,7 +1439,7 @@ HB_SIZE hb_fsPipeWrite( HB_FHANDLE hPipeHandle, const void * buffer, HB_SIZE nSi
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv;
|
||||
fd_set wfds;
|
||||
# if ! defined( HB_HAS_SELECT_TIMER )
|
||||
@@ -1476,7 +1487,7 @@ HB_SIZE hb_fsPipeWrite( HB_FHANDLE hPipeHandle, const void * buffer, HB_SIZE nSi
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
|
||||
if( iResult > 0 )
|
||||
{
|
||||
|
||||
@@ -579,7 +579,7 @@ static int hb_comCanRead( PHB_COM pCom, HB_MAXINT timeout )
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv;
|
||||
fd_set rfds;
|
||||
|
||||
@@ -630,7 +630,7 @@ static int hb_comCanRead( PHB_COM pCom, HB_MAXINT timeout )
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
|
||||
return iResult;
|
||||
}
|
||||
@@ -683,7 +683,7 @@ static int hb_comCanWrite( PHB_COM pCom, HB_MAXINT timeout )
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv;
|
||||
fd_set wfds;
|
||||
|
||||
@@ -713,7 +713,7 @@ static int hb_comCanWrite( PHB_COM pCom, HB_MAXINT timeout )
|
||||
# endif
|
||||
|
||||
iResult = select( ( int ) ( pCom->fd + 1 ), NULL, &wfds, NULL, &tv );
|
||||
if( iResult > 0 && FD_ISSET( pCom->fd, &wfds ) )
|
||||
if( iResult > 0 && ! FD_ISSET( pCom->fd, &wfds ) )
|
||||
iResult = 0;
|
||||
hb_comSetOsError( pCom, iResult == -1 );
|
||||
if( iResult == 0 && timeout < 0 && hb_vmRequestQuery() == 0 )
|
||||
@@ -735,7 +735,7 @@ static int hb_comCanWrite( PHB_COM pCom, HB_MAXINT timeout )
|
||||
# endif
|
||||
break;
|
||||
}
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
|
||||
return iResult;
|
||||
}
|
||||
|
||||
@@ -1552,7 +1552,7 @@ int hb_fsProcessRun( const char * pszFileName,
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
{
|
||||
fd_set rfds, wfds, *prfds, *pwfds;
|
||||
HB_FHANDLE fdMax;
|
||||
@@ -1598,7 +1598,7 @@ int hb_fsProcessRun( const char * pszFileName,
|
||||
fStderr = hStderr != FS_ERROR && FD_ISSET( hStderr, &rfds );
|
||||
fStdin = hStdin != FS_ERROR && FD_ISSET( hStdin, &wfds );
|
||||
}
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
|
||||
if( fStdout )
|
||||
{
|
||||
|
||||
@@ -1540,7 +1540,7 @@ static int hb_socketSelectRD( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
break;
|
||||
}
|
||||
return iResult;
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv, * ptv;
|
||||
fd_set rfds;
|
||||
int iResult, iError;
|
||||
@@ -1591,7 +1591,7 @@ static int hb_socketSelectRD( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
|
||||
return iResult < 0 ? -1 :
|
||||
( iResult > 0 && FD_ISSET( ( HB_SOCKET_T ) sd, &rfds ) ? 1 : 0 );
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
}
|
||||
|
||||
static int hb_socketSelectWR( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
@@ -1649,7 +1649,7 @@ static int hb_socketSelectWR( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
break;
|
||||
}
|
||||
return iResult;
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv, * ptv;
|
||||
fd_set wfds;
|
||||
int iResult, iError;
|
||||
@@ -1700,7 +1700,7 @@ static int hb_socketSelectWR( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
|
||||
return iResult < 0 ? -1 :
|
||||
( iResult > 0 && FD_ISSET( ( HB_SOCKET_T ) sd, &wfds ) ? 1 : 0 );
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
}
|
||||
|
||||
static int hb_socketSelectWRE( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
@@ -1770,7 +1770,7 @@ static int hb_socketSelectWRE( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
hb_socketSetOsError( iError );
|
||||
}
|
||||
return iResult;
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
struct timeval tv, * ptv;
|
||||
fd_set wfds, * pefds;
|
||||
|
||||
@@ -1862,7 +1862,7 @@ static int hb_socketSelectWRE( HB_SOCKET sd, HB_MAXINT timeout )
|
||||
|
||||
return iResult < 0 ? -1 :
|
||||
( iResult > 0 && FD_ISSET( ( HB_SOCKET_T ) sd, &wfds ) ? 1 : 0 );
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
}
|
||||
|
||||
int hb_socketGetAddrFamily( const void * pSockAddr, unsigned len )
|
||||
@@ -3107,7 +3107,7 @@ int hb_socketSelect( PHB_ITEM pArrayRD, HB_BOOL fSetRD,
|
||||
hb_xfree( pfds );
|
||||
|
||||
return iResult;
|
||||
#else
|
||||
#else /* ! HB_HAS_POLL */
|
||||
HB_SOCKET maxsd, sd;
|
||||
int i, ret;
|
||||
HB_SIZE nLen, nPos, ul;
|
||||
@@ -3198,7 +3198,7 @@ int hb_socketSelect( PHB_ITEM pArrayRD, HB_BOOL fSetRD,
|
||||
}
|
||||
|
||||
return ret;
|
||||
#endif /* HB_HAS_POLL */
|
||||
#endif /* ! HB_HAS_POLL */
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user