Be more verbose about 'error 101' - when using the server browser on machines with unroutable ipv6.

Fix some issues reported by xaGe including a serious linux one.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5225 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-03-07 20:31:09 +00:00
parent 986131b191
commit cfa28262b4
6 changed files with 30 additions and 15 deletions

View file

@ -834,7 +834,7 @@ static qintptr_t UI_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con
}
else if (!strncmp(cmdtext, "localservers", 12))
{
extern void NET_SendPollPacket(int len, void *data, netadr_t to);
extern qboolean NET_SendPollPacket(int len, void *data, netadr_t to);
netadr_t na;
MasterInfo_Refresh();

View file

@ -408,7 +408,7 @@ static void SL_PreDraw (menu_t *menu)
info->numslots = Master_NumSorted();
snprintf(info->refreshtext, sizeof(info->refreshtext), "Refresh - %u/%u/%u\n", info->numslots, Master_NumAlive(), Master_TotalCount());
}
void NET_SendPollPacket(int len, void *data, netadr_t to);
qboolean NET_SendPollPacket(int len, void *data, netadr_t to);
static void SL_PostDraw (menu_t *menu)
{
static char *helpstrings[] =

View file

@ -1793,11 +1793,12 @@ qboolean Master_LoadMasterList (char *filename, qboolean withcomment, int defaul
return true;
}
void NET_SendPollPacket(int len, void *data, netadr_t to)
qboolean NET_SendPollPacket(int len, void *data, netadr_t to)
{
unsigned long bcast;
int ret;
struct sockaddr_qstorage addr;
char buf[128];
NetadrToSockadr (&to, &addr);
#ifdef USEIPX
@ -1818,7 +1819,7 @@ void NET_SendPollPacket(int len, void *data, netadr_t to)
if (pollsocketsBCast[FIRSTIPXSOCKET+lastpollsockIPX] != bcast)
{
if (setsockopt(pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX], SOL_SOCKET, SO_BROADCAST, (char *)&bcast, sizeof(bcast)) == -1)
return;
return true;
pollsocketsBCast[FIRSTIPXSOCKET+lastpollsockIPX] = bcast;
}
ret = sendto (pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX], data, len, 0, (struct sockaddr *)&addr, sizeof(addr) );
@ -1837,7 +1838,7 @@ void NET_SendPollPacket(int len, void *data, netadr_t to)
pollsocketsBCast[FIRSTUDP6SOCKET+lastpollsockUDP6] = false;
}
if (pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6]==INVALID_SOCKET)
return; //bother
return true; //bother
ret = sendto (pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6], data, len, 0, (struct sockaddr *)&addr, sizeof(addr) );
}
else
@ -1854,36 +1855,47 @@ void NET_SendPollPacket(int len, void *data, netadr_t to)
pollsocketsBCast[FIRSTUDP4SOCKET+lastpollsockUDP4] = false;
}
if (pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4]==INVALID_SOCKET)
return; //bother
return true; //bother
bcast = !memcmp(to.address.ip, "\xff\xff\xff\xff", sizeof(to.address.ip));
if (pollsocketsBCast[FIRSTUDP4SOCKET+lastpollsockUDP4] != bcast)
{
if (setsockopt(pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4], SOL_SOCKET, SO_BROADCAST, (char *)&bcast, sizeof(bcast)) == -1)
return;
return true;
pollsocketsBCast[FIRSTUDP4SOCKET+lastpollsockUDP4] = bcast;
}
ret = sendto (pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4], data, len, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in) );
}
else
#endif
return;
return true;
if (ret == -1)
{
int er = neterrno();
// wouldblock is silent
if (er == NET_EWOULDBLOCK)
return;
return false;
if (er == NET_ECONNREFUSED)
return;
return true;
if (er == NET_ENETUNREACH)
Con_Printf("NET_SendPollPacket Warning: unreachable: %s\n", NET_AdrToString(buf, sizeof(buf), &to));
else
#ifdef _WIN32
if (er == NET_EADDRNOTAVAIL)
Con_DPrintf("NET_SendPollPacket Warning: %i\n", er);
else
Con_Printf ("NET_SendPollPacket ERROR: %i\n", er);
#else
if (er == NET_EADDRNOTAVAIL)
Con_DPrintf("NET_SendPollPacket Warning: %s\n", strerror(er));
else
Con_Printf ("NET_SendPollPacket ERROR: %s\n", strerror(er));
#endif
}
return true;
}
int Master_CheckPollSockets(void)
@ -1930,7 +1942,7 @@ int Master_CheckPollSockets(void)
SockadrToNetadr (&from, &net_from);
net_message.cursize = ret;
if (ret == sizeof(net_message_buffer) )
if (ret >= sizeof(net_message_buffer) )
{
Con_Printf ("Oversize packet from %s\n", NET_AdrToString (adr, sizeof(adr), &net_from));
continue;
@ -2690,7 +2702,8 @@ void Master_QueryServer(serverinfo_t *server)
default:
return;
}
NET_SendPollPacket (strlen(data), data, server->adr);
if (!NET_SendPollPacket (strlen(data), data, server->adr))
server->sends++; //if we failed, just try again later
}
//send a packet to each server in sequence.
qboolean CL_QueryServers(void)

View file

@ -171,6 +171,7 @@
#define NET_ENOTCONN WSAENOTCONN
#define NET_EACCES WSAEACCES
#define NET_EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define NET_ENETUNREACH WSAENETUNREACH
#define NET_EAFNOSUPPORT WSAEAFNOSUPPORT
#elif defined(__MORPHOS__) && !defined(ixemul)
#define neterrno() Errno()
@ -190,6 +191,7 @@
#define NET_ENOTCONN ENOTCONN
#define NET_EACCES EACCES
#define NET_EADDRNOTAVAIL EADDRNOTAVAIL
#define NET_ENETUNREACH ENETUNREACH
#define NET_EAFNOSUPPORT EAFNOSUPPORT
#endif

View file

@ -1143,7 +1143,7 @@ static struct
qboolean abs;
double min, max;
float old;
} axis[2];
} axis[2]; //the meaning of any other axis is unknown. beware that they DO happen.
qboolean abs;
} *deviceinfo;
int nextqdev;
@ -1176,7 +1176,7 @@ static struct xidevinfo *XI2_GetDeviceInfo(int devid)
if (dev->classes[j]->sourceid == xi2.ndeviceinfos && dev->classes[j]->type == XIValuatorClass)
{
XIValuatorClassInfo *v = (XIValuatorClassInfo*)dev->classes[j];
if (v->mode == XIModeAbsolute)
if (v->mode == XIModeAbsolute && v->number >= 0 && v->number < countof(xi2.deviceinfo[xi2.ndeviceinfos].axis))
{
xi2.deviceinfo[xi2.ndeviceinfos].abs = xi2.deviceinfo[xi2.ndeviceinfos].axis[v->number].abs = true;
xi2.deviceinfo[xi2.ndeviceinfos].axis[v->number].min = v->min;

View file

@ -49,7 +49,7 @@ byte *StringToRGB(const char *str)
int i;
for (i = 0; i < 4; i++)
{
while(*str <= ' ')
while(*str && *str <= ' ')
str++;
if (!*str)
rgba[i] = 255;