From ebac90e94b3e6eafedc25b977507ad97d1feb703 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 14 Apr 2006 00:59:29 +0000 Subject: [PATCH] Trying to make QTV more robust with connecting to remote sources. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2199 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- fteqtv/qtv.h | 1 + fteqtv/qw.c | 2 +- fteqtv/source.c | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fteqtv/qtv.h b/fteqtv/qtv.h index fe9e9dd24..1f5e27bc7 100644 --- a/fteqtv/qtv.h +++ b/fteqtv/qtv.h @@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define qerrno WSAGetLastError() #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS + #define ENOTCONN WSAENOTCONN #ifdef _MSC_VER //okay, so warnings are here to help... they're ugly though. diff --git a/fteqtv/qw.c b/fteqtv/qw.c index 2039c36f5..0f2497e99 100644 --- a/fteqtv/qw.c +++ b/fteqtv/qw.c @@ -1147,7 +1147,7 @@ void UpdateStats(sv_t *qtv, viewer_t *v) if (qtv && qtv->controller == v) stats = qtv->players[qtv->thisplayer].stats; - else if (v->trackplayer < 0 || !qtv) + else if (v->trackplayer != -1 || !qtv) stats = nullstats; else stats = qtv->players[v->trackplayer].stats; diff --git a/fteqtv/source.c b/fteqtv/source.c index e4dea16a4..741da8bfa 100644 --- a/fteqtv/source.c +++ b/fteqtv/source.c @@ -244,7 +244,7 @@ qboolean Net_ConnectToTCPServer(sv_t *qtv, char *ip) if (connect(qtv->sourcesock, (struct sockaddr *)&qtv->serveraddress, sizeof(qtv->serveraddress)) == INVALID_SOCKET) { - if (qerrno != EINPROGRESS) + if (qerrno != EINPROGRESS && qerrno != EWOULDBLOCK) //bsd sockets are meant to return EINPROGRESS, but some winsock drivers use EWOULDBLOCK instead. *sigh*... { closesocket(qtv->sourcesock); qtv->sourcesock = INVALID_SOCKET; @@ -707,6 +707,7 @@ qboolean Net_ReadStream(sv_t *qtv) int maxreadable; int read; char *buffer; + int err; maxreadable = MAX_PROXY_BUFFER - qtv->buffersize; if (!maxreadable) @@ -733,7 +734,8 @@ qboolean Net_ReadStream(sv_t *qtv) } else { - if (read == 0 || qerrno != EWOULDBLOCK) + err = qerrno; + if (read == 0 || (err != EWOULDBLOCK && err != ENOTCONN)) //ENOTCONN can be returned whilst waiting for a connect to finish. { if (qtv->sourcesock != INVALID_SOCKET) {