2010-01-29 20:11 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbtpathy/telepath.prg
    ! Fixed "midnight bug" in several TP functions having timeout option
      (it was wrong in all places).
      Reported by AbeB.
    ; Please review/test, I didn't make _any_ testing whatsoever.
This commit is contained in:
Viktor Szakats
2010-01-29 19:12:54 +00:00
parent b057311da3
commit 56de51fe3a
2 changed files with 36 additions and 24 deletions

View File

@@ -17,6 +17,13 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-01-29 20:11 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtpathy/telepath.prg
! Fixed "midnight bug" in several TP functions having timeout option
(it was wrong in all places).
Reported by AbeB.
; Please review/test, I didn't make _any_ testing whatsoever.
2010-01-29 18:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/hbsocket.c
* do not try to resolve NULL or empty addresses in hb_socketResolveAddr()
@@ -57,7 +64,7 @@
! Cleaned :pPtr := 0 => :pPtr := NIL
+ Implemented QBuffer() class which allows to load .u
from .prg embedding or from database.
2010-01-29 13:09 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rdd/dbfcdx/dbfcdx1.c
! fixed possible unreleased lock after last modification in SIXCDX -
@@ -66,7 +73,7 @@
2010-01-28 18:03 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/filelist.mk
+ contrib/hbqt/THbpQtUI.prg
- contrib/hbxbp/hbpqtui.prg
* contrib/hbxbp/Makefile
* contrib/hbxbp/xbpdialog.prg
@@ -400,7 +407,7 @@
got broken for some reason.
* utils/hbmk2/hbmk2.prg
! Fixed entry function detection builting project in
! Fixed entry function detection building project in
different than current dir, possibly also in -inc mode.
[TOMERGE 2.0]
@@ -425,6 +432,7 @@
* harbour/contrib/hbwin/win_misc.c
! fixed buffer overflow in WIN_WIDETOANSI() caused by wrongly calculated
buffer size
[TOMERGE 2.0]
* harbour/utils/hbmk2/hbmk2.prg
* updated names of xHarbour libraries - now it works in static mode

View File

@@ -266,9 +266,12 @@ FUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortn
RETURN TE_CONFL // maybe should return something different?
STATIC FUNCTION __tp_timeelapsed( nStartSec, nEndSec )
RETURN ( nEndSec - iif( nEndSec < nStartSec, nStartSec - 86399, nStartSec ) )
FUNCTION tp_recv( nPort, nLength, nTimeout )
LOCAL nDone
LOCAL nStartSec
LOCAL cRet
DEFAULT nLength TO t_aPorts[ nPort, TPFP_INBUF_SIZE ]
@@ -276,11 +279,10 @@ FUNCTION tp_recv( nPort, nLength, nTimeout )
FetchChars( nPort )
nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )
DO WHILE Len( t_aPorts[ nPort, TPFP_INBUF ] ) < nLength .AND.;
( nTimeout < 0 .OR. Seconds() < nDone )
nStartSec := Seconds()
DO WHILE Len( t_aPorts[ nPort, TPFP_INBUF ] ) < nLength .AND. ;
( nTimeout < 0 .OR. __tp_timeelapsed( nStartSec, Seconds() ) < nTimeout )
IF ! tp_idle()
FetchChars( nPort )
ELSE
@@ -300,7 +302,8 @@ FUNCTION tp_recv( nPort, nLength, nTimeout )
FUNCTION tp_send( nPort, cString, nTimeout )
LOCAL nWritten, nTotWritten, nDone
LOCAL nWritten, nTotWritten
LOCAL nStartSec
DEFAULT cString TO ""
DEFAULT nTimeout TO 0
@@ -313,11 +316,12 @@ FUNCTION tp_send( nPort, cString, nTimeout )
RETURN 0
ENDIF
nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0)
nStartSec := Seconds()
nTotWritten := 0
DO WHILE nTotWritten < Len( cString ) .AND. ;
( nTimeout < 0 .OR. Seconds() <= nDone )
( nTimeout < 0 .OR. __tp_timeelapsed( nStartSec, Seconds() ) < nTimeout )
nWritten := __tp_WritePort( t_aPorts[ nPort, TPFP_HANDLE ], SubStr( cString, nTotWritten + 1 ) )
@@ -354,14 +358,15 @@ FUNCTION tp_recvto( nPort, cDelim, nMaxlen, nTimeout )
LOCAL cChar
LOCAL nAt
LOCAL nStartPos := 1, nFirst := 0
LOCAL nDone, cRet := ""
LOCAL cRet := ""
LOCAL nStartSec
IF ! isopenport( nPort )
RETURN ""
RETURN cRet
ENDIF
IF ! ISCHARACTER( cDelim ) .OR. Len( cDelim ) == 0
RETURN ""
RETURN cRet
ENDIF
DEFAULT nMaxlen TO 64999 /* dos telepathy def. on xharbour could be higher */
@@ -372,12 +377,12 @@ FUNCTION tp_recvto( nPort, cDelim, nMaxlen, nTimeout )
/* Telepathy ng: [...] If nTimeout is omitted or zero, reads until finding the
delimiter or the input buffer is empty. */
IF nTimeout == 0 .AND. Len( t_aPorts[ nPort, TPFP_INBUF ] ) == 0
RETURN ""
RETURN cRet
ENDIF
nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )
nStartSec := Seconds()
DO WHILE ( nTimeout < 0 .OR. Seconds() < nDone )
DO WHILE __tp_timeelapsed( nStartSec, Seconds() ) < nTimeout
IF Len( cDelim ) == 1
@@ -643,7 +648,7 @@ FUNCTION tp_iscts( nPort )
// I'll wait as long as it takes to drain the port.
FUNCTION tp_flush( nPort, nTimeout )
//LOCAL nStart := Seconds()
//LOCAL nStartSec := Seconds()
LOCAL nRes
DEFAULT nTimeout TO 0
@@ -656,8 +661,8 @@ FUNCTION tp_flush( nPort, nTimeout )
// Sleep rest of timeout
/*
IF nTimeout > 0 .AND. Seconds() - nStart < nTimeout
hb_idleSleep( nTimeout - ( Seconds() - nStart ) )
IF nTimeout > 0 .AND. __tp_timeelapsed( nStartSec, Seconds() ) > nTimeout
hb_idleSleep( nTimeout - __tp_timeelapsed( nStartSec, Seconds() ) )
ENDIF
*/
@@ -669,7 +674,7 @@ FUNCTION tp_flush( nPort, nTimeout )
FUNCTION tp_flush( nPort, nTimeout )
LOCAL nDone
LOCAL nStartSec
DEFAULT nTimeout TO -1
@@ -681,10 +686,9 @@ FUNCTION tp_flush( nPort, nTimeout )
nTimeout := 1800
ENDIF
nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )
nStartSec := Seconds()
DO WHILE tp_OutFree( nPort ) > 0 .AND. ;
( nTimeout < 0 .OR. Seconds() < nDone )
DO WHILE tp_OutFree( nPort ) > 0 .AND. __tp_timeelapsed( nStartSec, Seconds() ) < nTimeout
hb_IdleState()
ENDDO