From 50ebdd772e88fdd9c3e0514bd2c662b42a20a43d Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 28 Jul 2009 16:54:33 +0000 Subject: [PATCH] 2009-07-28 18:54 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/hbsocket.c * return -1 instead of 0 on timeout in hb_socketSend*() and hb_socketRecv*() functions --- harbour/ChangeLog | 5 +++++ harbour/source/rtl/hbsocket.c | 36 ++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ef3354f607..6ccbc26b87 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-28 18:54 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/hbsocket.c + * return -1 instead of 0 on timeout in hb_socketSend*() and + hb_socketRecv*() functions + 2009-07-28 18:22 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * bin/hb-func.sh * make_gnu.sh diff --git a/harbour/source/rtl/hbsocket.c b/harbour/source/rtl/hbsocket.c index 88ea099746..a10263fe3e 100644 --- a/harbour/source/rtl/hbsocket.c +++ b/harbour/source/rtl/hbsocket.c @@ -2070,20 +2070,19 @@ int hb_socketConnect( HB_SOCKET sd, const void * pSockAddr, unsigned uiLen, HB_L long hb_socketSend( HB_SOCKET sd, const void * data, long len, int flags, HB_LONG timeout ) { long lSent = 0; - int ret = 0; hb_vmUnlock(); if( timeout >= 0 ) { - ret = hb_socketSelectWR( sd, timeout ); - if( ret == 0 ) + lSent = hb_socketSelectWR( sd, timeout ); + if( lSent == 0 ) { hb_socketSetRawError( HB_SOCKET_ERR_TIMEOUT ); - ret = -1; + lSent = -1; } } - if( ret >= 0 ) + if( lSent >= 0 ) { /* in POSIX systems writing data to broken connection stream causes * that system generates SIGPIPE which has to be caught by application @@ -2109,20 +2108,19 @@ long hb_socketSendTo( HB_SOCKET sd, const void * data, long len, int flags, const void * pSockAddr, unsigned uiSockLen, HB_LONG timeout ) { long lSent = 0; - int ret = 0; hb_vmUnlock(); if( timeout >= 0 ) { - ret = hb_socketSelectWR( sd, timeout ); - if( ret == 0 ) + lSent = hb_socketSelectWR( sd, timeout ); + if( lSent == 0 ) { hb_socketSetRawError( HB_SOCKET_ERR_TIMEOUT ); - ret = -1; + lSent = -1; } } - if( ret >= 0 ) + if( lSent >= 0 ) { /* see note above about SIGPIPE */ #if defined( MSG_NOSIGNAL ) @@ -2144,20 +2142,19 @@ long hb_socketSendTo( HB_SOCKET sd, const void * data, long len, int flags, long hb_socketRecv( HB_SOCKET sd, void * data, long len, int flags, HB_LONG timeout ) { long lReceived = 0; - int ret = 0; hb_vmUnlock(); if( timeout >= 0 ) { - ret = hb_socketSelectRD( sd, timeout ); - if( ret == 0 ) + lReceived = hb_socketSelectRD( sd, timeout ); + if( lReceived == 0 ) { hb_socketSetRawError( HB_SOCKET_ERR_TIMEOUT ); - ret = -1; + lReceived = -1; } } - if( ret >= 0 ) + if( lReceived >= 0 ) { do { @@ -2174,20 +2171,19 @@ long hb_socketRecv( HB_SOCKET sd, void * data, long len, int flags, HB_LONG time long hb_socketRecvFrom( HB_SOCKET sd, void * data, long len, int flags, void ** pSockAddr, unsigned * puiSockLen, HB_LONG timeout ) { long lReceived = 0; - int ret = 0; hb_vmUnlock(); if( timeout >= 0 ) { - ret = hb_socketSelectRD( sd, timeout ); - if( ret == 0 ) + lReceived = hb_socketSelectRD( sd, timeout ); + if( lReceived == 0 ) { hb_socketSetRawError( HB_SOCKET_ERR_TIMEOUT ); - ret = -1; + lReceived = -1; } } - if( ret >= 0 ) + if( lReceived >= 0 ) { #if defined( HB_HAS_SOCKADDR_STORAGE ) struct sockaddr_storage st;