(Netplay) Copy data on receive, even if the buffer is full (#14344)
This commit is contained in:
parent
9aef0eff90
commit
b59624adc8
|
@ -2371,7 +2371,7 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
if (buf_used(sbuf) >= (sbuf->bufsz - 1))
|
if (buf_used(sbuf) >= (sbuf->bufsz - 1))
|
||||||
return 0;
|
goto copy;
|
||||||
|
|
||||||
/* Receive whatever we can into the buffer */
|
/* Receive whatever we can into the buffer */
|
||||||
if (sbuf->end >= sbuf->start)
|
if (sbuf->end >= sbuf->start)
|
||||||
|
@ -2415,6 +2415,7 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now copy it into the reader */
|
/* Now copy it into the reader */
|
||||||
|
copy:
|
||||||
if (sbuf->end >= sbuf->read || (sbuf->bufsz - sbuf->read) >= len)
|
if (sbuf->end >= sbuf->read || (sbuf->bufsz - sbuf->read) >= len)
|
||||||
{
|
{
|
||||||
size_t unread = buf_unread(sbuf);
|
size_t unread = buf_unread(sbuf);
|
||||||
|
@ -2426,7 +2427,6 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
|
||||||
if (sbuf->read >= sbuf->bufsz)
|
if (sbuf->read >= sbuf->bufsz)
|
||||||
sbuf->read = 0;
|
sbuf->read = 0;
|
||||||
recvd = len;
|
recvd = len;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (unread > 0)
|
else if (unread > 0)
|
||||||
{
|
{
|
||||||
|
@ -2442,8 +2442,8 @@ ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Our read goes around the edge */
|
/* Our read goes around the edge */
|
||||||
size_t chunka = sbuf->bufsz - sbuf->read;
|
size_t chunka = sbuf->bufsz - sbuf->read;
|
||||||
size_t chunkb = ((len - chunka) > sbuf->end) ? sbuf->end :
|
size_t chunkb = ((len - chunka) > sbuf->end) ? sbuf->end :
|
||||||
(len - chunka);
|
(len - chunka);
|
||||||
|
|
||||||
memcpy(buf, sbuf->data + sbuf->read, chunka);
|
memcpy(buf, sbuf->data + sbuf->read, chunka);
|
||||||
|
|
Loading…
Reference in New Issue