Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow sock_recv to cope with short reads

I have observed on Linux that without this change reads are limited to the MTU
of the interface used for TCP communication, module any affects of LRO.
  • Loading branch information...
commit d06a5b9586e697ecdc55ec9b1b6c35594e1aac5d 1 parent 5623e2b
@horms authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/riack_sock.c
View
20 src/riack_sock.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#ifdef WIN32
#include <winsock2.h>
@@ -134,7 +135,24 @@ int sock_set_timeouts(int sockfd, uint32_t recv_timeout, uint32_t send_timeout)
}
int sock_recv(int sockfd, uint8_t* buff, int len)
{
- return recv(sockfd, (char*)buff, len, 0);
+ int offset = 0;
+
+ while (offset < len) {
+ int recieved;
+ recieved = recv(sockfd, (char*)buff + offset, len - offset, 0);
+ if (recieved < 0) {
+ if (errno == EINTR) {
+ /* Try again */
+ continue;
+ }
+ return recieved;
+ }
+ if (recieved == 0) {
+ break;
+ }
+ offset += recieved;
+ }
+ return offset;
}
int sock_send(int sockfd, uint8_t* data, int len)
Please sign in to comment.
Something went wrong with that request. Please try again.