Error reporting when a password is refused, plus a bugfix so that

socket_receive_all_nonblocking actually reports disconnects.
This commit is contained in:
Gregor Richards 2016-12-15 12:15:02 -05:00
parent df2600fbf4
commit a6cd8c3aa1
2 changed files with 13 additions and 1 deletions

View File

@ -74,9 +74,16 @@ ssize_t socket_receive_all_nonblocking(int fd, bool *error,
const uint8_t *data = (const uint8_t*)data_;
ssize_t ret = recv(fd, (char*)data, size, 0);
if (ret >= 0)
if (ret > 0)
return ret;
if (ret == 0)
{
/* Socket closed */
*error = true;
return -1;
}
if (isagain(ret))
return 0;

View File

@ -677,7 +677,12 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
retro_ctx_memory_info_t mem_info;
RECV(cmd, sizeof(cmd))
{
char *msg = "Incorrect password.";
RARCH_ERR("%s\n", msg);
runloop_msg_queue_push(msg, 1, 180, false);
return false;
}
/* Only expecting a sync command */
if (ntohl(cmd[0]) != NETPLAY_CMD_SYNC ||