[Harbour] Wrong hbsms
Przemysław Czerpak
druzus at acn.waw.pl
Thu Mar 4 06:51:04 EST 2010
On Thu, 04 Mar 2010, Szak�ts Viktor wrote:
Hi,
> Thank you very much Jaroslaw.
> This leads to these two changes (in three commits):
> http://harbour-project.svn.sourceforge.net/viewvc/harbour-project/trunk/harbour/contrib/hbtpathy/telepath.prg?r1=12142&r2=13735
> http://harbour-project.svn.sourceforge.net/viewvc/harbour-project/trunk/harbour/contrib/hbtpathy/telepath.prg?r1=13735&r2=13736
> http://harbour-project.svn.sourceforge.net/viewvc/harbour-project/trunk/harbour/contrib/hbtpathy/telepath.prg?r1=13736&r2=13737
> (which would have been a suspect anyway)
> I've reimplemented these two patches now,
> but still untested, could you please do
> a test with it?
The modifications was partially reverted so it's much easier to make:
svn diff -r 13589 telepath.prg > telepath.diff
Functionally you changed one thing:
tp_send() uses now:
DO WHILE nTotWritten < Len( cString ) .AND. ;
( nTimeout < 0 .OR. ( hb_milliSeconds() - nStartTime ) < nTimeout )
^^^
and the previous code was using:
DO WHILE nTotWritten < Len( cString ) .AND. ;
( nTimeout < 0 .OR. Seconds() <= nDone )
^^^^
minor difference but it's bug exploited by upper level code which does not
set any timeout like hbsms.prg.
BTW hbsms.prg should be fixed because current code which does not use any
timeout and does not check number of sent bytes to resend the rest is
simply wrong and may randomly fail.
Original code which used nDone variable was more efficient then current
one using nStartTime because time difference was calculated once at startup.
The optimal code should make sth like:
nStopTime := IIF( nTimeout > 0, hb_milliSeconds() + nTimeOut * 1000 : 0 )
[...]
WHILE .T.
[...]
IF nTimeOut <= 0 .OR. hb_milliSeconds() >= nStopTime
EXIT
ENDDO
ENDDO
It eliminates unnecessary calculations and hb_milliSeconds() calls.
best regards,
Przemek
More information about the Harbour
mailing list