Skip to content

Commit

Permalink
(Netplay) Do not try to receive new data if the data is in the buffer (
Browse files Browse the repository at this point in the history
  • Loading branch information
Cthulhu-throwaway authored Aug 24, 2022
1 parent 72cc98e commit ea9dd02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions network/netplay/netplay_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
ssize_t recvd;
bool error = false;

if (buf_used(sbuf) >= (sbuf->bufsz - 1))
if (buf_unread(sbuf) >= len || !buf_remaining(sbuf))
goto copy;

/* Receive whatever we can into the buffer */
Expand All @@ -2389,7 +2389,7 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
{
sbuf->end = 0;

if (sbuf->start > 1)
if (sbuf->start > 1 && buf_unread(sbuf) < len)
{
error = false;
recvd = socket_receive_all_nonblocking(sockfd, &error,
Expand Down

0 comments on commit ea9dd02

Please sign in to comment.