Fixed mistake where available buffer size would not be updated for each recvfrom-call in PacketPeerUDPWinsockPposix.

This commit is contained in:
Trond Abusdal 2015-11-19 19:06:01 +01:00
parent 41a161647d
commit a8a2458f0b
2 changed files with 2 additions and 6 deletions

View file

@ -120,10 +120,8 @@ Error PacketPeerUDPPosix::_poll(bool p_wait) {
struct sockaddr_in from = {0};
socklen_t len = sizeof(struct sockaddr_in);
int rb_size = MAX(rb.space_left()-12, 0);
int buffer_size = MIN((int)sizeof(recv_buffer),rb_size);
int ret;
while ( (ret = recvfrom(sockfd, recv_buffer, buffer_size, p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) {
while ( (ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) {
rb.write((uint8_t*)&from.sin_addr, 4);
uint32_t port = ntohs(from.sin_port);
rb.write((uint8_t*)&port, 4);

View file

@ -120,10 +120,8 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) {
struct sockaddr_in from = {0};
int len = sizeof(struct sockaddr_in);
int rb_size = MAX(rb.space_left()-12, 0);
int buffer_size = MIN((int)sizeof(recv_buffer),rb_size);
int ret;
while ( (ret = recvfrom(sockfd, (char*)recv_buffer, buffer_size, 0, (struct sockaddr*)&from, &len)) > 0) {
while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), 0, (struct sockaddr*)&from, &len)) > 0) {
rb.write((uint8_t*)&from.sin_addr, 4);
uint32_t port = ntohs(from.sin_port);
rb.write((uint8_t*)&port, 4);