(netplay.c) Simplify init_tcp_connection

This commit is contained in:
twinaphex 2015-01-09 03:00:24 +01:00
parent 8ce32e01cd
commit d4a08d7ec7
2 changed files with 12 additions and 24 deletions

View File

@ -90,9 +90,7 @@ static void video_frame(const void *data, unsigned width,
if (g_extern.filter.filter && data) if (g_extern.filter.filter && data)
{ {
unsigned owidth = 0; unsigned owidth = 0, oheight = 0, opitch = 0;
unsigned oheight = 0;
unsigned opitch = 0;
rarch_softfilter_get_output_size(g_extern.filter.filter, rarch_softfilter_get_output_size(g_extern.filter.filter,
&owidth, &oheight, width, height); &owidth, &oheight, width, height);
@ -469,7 +467,6 @@ static int16_t input_state(unsigned port, unsigned device,
* input_poll_overlay: * input_poll_overlay:
* *
* Poll pressed buttons/keys on currently active overlay. * Poll pressed buttons/keys on currently active overlay.
*
**/ **/
static inline void input_poll_overlay(void) static inline void input_poll_overlay(void)
{ {

View File

@ -285,30 +285,20 @@ static int init_tcp_connection(const struct addrinfo *res,
goto end; goto end;
} }
} }
else if (spectate)
{
int yes = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 ||
listen(fd, MAX_SPECTATORS) < 0)
{
ret = false;
goto end;
}
}
else else
{ {
int yes = 1; int yes = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int)); setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 || if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 ||
listen(fd, 1) < 0) listen(fd, spectate ? MAX_SPECTATORS : 1) < 0)
{ {
ret = false; ret = false;
goto end; goto end;
} }
if (!spectate)
{
int new_fd = accept(fd, other_addr, &addr_size); int new_fd = accept(fd, other_addr, &addr_size);
if (new_fd < 0) if (new_fd < 0)
{ {
@ -319,6 +309,7 @@ static int init_tcp_connection(const struct addrinfo *res,
close(fd); close(fd);
fd = new_fd; fd = new_fd;
} }
}
end: end:
if (!ret && fd >= 0) if (!ret && fd >= 0)