Revert "Merge branch 'mserv-is-dumb-and-what-else-is-new' into 'master'"

This reverts merge request !688
This commit is contained in:
Alam Ed Arias 2020-01-17 01:42:40 +00:00
parent 098e41e518
commit 1f77551162

View file

@ -323,7 +323,7 @@ static INT32 GetServersList(void)
// //
// MS_Connect() // MS_Connect()
// //
static INT32 MS_SubConnect(const char *ip_addr, const char *str_port, INT32 async, struct sockaddr *bindaddr, socklen_t bindaddrlen) static INT32 MS_Connect(const char *ip_addr, const char *str_port, INT32 async)
{ {
#ifdef NONET #ifdef NONET
(void)ip_addr; (void)ip_addr;
@ -355,8 +355,6 @@ static INT32 MS_SubConnect(const char *ip_addr, const char *str_port, INT32 asyn
{ {
socket_fd = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol); socket_fd = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol);
if (socket_fd != (SOCKET_TYPE)ERRSOCKET) if (socket_fd != (SOCKET_TYPE)ERRSOCKET)
{
if (!bindaddr || bind(socket_fd, bindaddr, bindaddrlen) == 0)
{ {
if (async) // do asynchronous connection if (async) // do asynchronous connection
{ {
@ -397,8 +395,6 @@ static INT32 MS_SubConnect(const char *ip_addr, const char *str_port, INT32 asyn
return 0; return 0;
} }
} }
close(socket_fd);
}
runp = runp->ai_next; runp = runp->ai_next;
} }
I_freeaddrinfo(ai); I_freeaddrinfo(ai);
@ -406,45 +402,6 @@ static INT32 MS_SubConnect(const char *ip_addr, const char *str_port, INT32 asyn
return MS_CONNECT_ERROR; return MS_CONNECT_ERROR;
} }
static INT32 MS_Connect(const char *ip_addr, const char *str_port, INT32 async)
{
const char *lhost;
struct my_addrinfo hints;
struct my_addrinfo *ai, *aip;
int c;
if (M_CheckParm("-bindaddr") && ( lhost = M_GetNextParm() ))
{
memset (&hints, 0x00, sizeof(hints));
#ifdef AI_ADDRCONFIG
hints.ai_flags = AI_ADDRCONFIG;
#endif
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (( c = I_getaddrinfo(lhost, 0, &hints, &ai) ) != 0)
{
CONS_Printf(
"mserv.c: bind to %s: %s\n",
lhost,
gai_strerror(c));
return MS_GETHOSTBYNAME_ERROR;
}
for (aip = ai; aip; aip = aip->ai_next)
{
c = MS_SubConnect(ip_addr, str_port, async, aip->ai_addr, aip->ai_addrlen);
if (c == 0)
{
I_freeaddrinfo(ai);
return 0;
}
}
I_freeaddrinfo(ai);
return c;
}
else
return MS_SubConnect(ip_addr, str_port, async, 0, 0);
}
#define NUM_LIST_SERVER MAXSERVERLIST #define NUM_LIST_SERVER MAXSERVERLIST
const msg_server_t *GetShortServersList(INT32 room) const msg_server_t *GetShortServersList(INT32 room)
{ {