mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 22:51:57 +00:00
Try to avoid sigpipe errors from tcp connections.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6337 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
62622491f0
commit
b2df9b2b30
1 changed files with 19 additions and 3 deletions
|
@ -9415,7 +9415,7 @@ void NET_Shutdown (void)
|
|||
#ifdef HAVE_EPOLL
|
||||
#include <poll.h>
|
||||
#endif
|
||||
static qboolean VFSTCP_IsStillConnecting(SOCKET sock)
|
||||
static int VFSTCP_IsStillConnecting(SOCKET sock)
|
||||
{
|
||||
#ifdef HAVE_EPOLL
|
||||
//poll has no arbitrary fd limit. use it instead of select where possible.
|
||||
|
@ -9424,7 +9424,13 @@ static qboolean VFSTCP_IsStillConnecting(SOCKET sock)
|
|||
ourfd[0].events = POLLOUT;
|
||||
ourfd[0].revents = 0;
|
||||
if (!poll(ourfd, countof(ourfd), 0))
|
||||
{
|
||||
if (ourfd[0].revents & POLLERR)
|
||||
return VFS_ERROR_UNSPECIFIED;
|
||||
if (ourfd[0].revents & POLLHUP)
|
||||
return VFS_ERROR_REFUSED;
|
||||
return true; //no events yet.
|
||||
}
|
||||
#else
|
||||
//okay on windows where sock+1 is ignored, has issues when lots of other fds are already open (for any reason).
|
||||
fd_set fdw, fdx;
|
||||
|
@ -9468,7 +9474,10 @@ int QDECL VFSTCP_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestorea
|
|||
|
||||
if (tf->conpending)
|
||||
{
|
||||
if (VFSTCP_IsStillConnecting(tf->sock))
|
||||
trying = VFSTCP_IsStillConnecting(tf->sock);
|
||||
if (trying < 0)
|
||||
tf->readaborted = trying;
|
||||
else if (trying)
|
||||
return 0;
|
||||
tf->conpending = false;
|
||||
}
|
||||
|
@ -9556,7 +9565,14 @@ int QDECL VFSTCP_WriteBytes (struct vfsfile_s *file, const void *buffer, int byt
|
|||
|
||||
if (tf->conpending)
|
||||
{
|
||||
if (VFSTCP_IsStillConnecting(tf->sock))
|
||||
len = VFSTCP_IsStillConnecting(tf->sock);
|
||||
if (len < 0)
|
||||
{
|
||||
tf->writeaborted = true;
|
||||
tf->conpending = false;
|
||||
return len;
|
||||
}
|
||||
if (len)
|
||||
return 0;
|
||||
tf->conpending = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue