Commit 73cd92cfa6a3a6f59d335dbecea184f8dd0f3179

Authored by Georg Hopp
1 parent 2f6f4367

define max read block values

@@ -37,6 +37,9 @@ @@ -37,6 +37,9 @@
37 //#include "tr/interface/socket.h" 37 //#include "tr/interface/socket.h"
38 #include "tr/logger.h" 38 #include "tr/logger.h"
39 39
  40 +#define TR_UDP_MAX_READ_BLOCK 8 * 1024
  41 +#define TR_TCP_MAX_READ_BLOCK 256 * 1024
  42 +
40 typedef enum TR_e_socket_fin { 43 typedef enum TR_e_socket_fin {
41 TR_FIN_NO = 0, 44 TR_FIN_NO = 0,
42 TR_FIN_RD = 1, 45 TR_FIN_RD = 1,
@@ -89,10 +89,13 @@ static @@ -89,10 +89,13 @@ static
89 TR_RemoteData 89 TR_RemoteData
90 tcpSocketRecv(TR_Socket this, size_t size) 90 tcpSocketRecv(TR_Socket this, size_t size)
91 { 91 {
92 - unsigned char buffer[size = size>8192 ? 8192 : size];  
93 TR_RemoteData rdata = NULL; 92 TR_RemoteData rdata = NULL;
94 ssize_t received; 93 ssize_t received;
95 94
  95 + size = size>TR_TCP_MAX_READ_BLOCK ? TR_TCP_MAX_READ_BLOCK : size;
  96 +
  97 + unsigned char buffer[size];
  98 +
96 received = recv(this->handle, buffer, size, this->flags); 99 received = recv(this->handle, buffer, size, this->flags);
97 100
98 if (-1 == received) { 101 if (-1 == received) {
@@ -51,11 +51,14 @@ static @@ -51,11 +51,14 @@ static
51 TR_RemoteData 51 TR_RemoteData
52 udpSocketRecv(TR_Socket this, size_t size) 52 udpSocketRecv(TR_Socket this, size_t size)
53 { 53 {
54 - unsigned char buffer[size = size>8192 ? 8192 : size];  
55 ssize_t received; 54 ssize_t received;
56 TR_RemoteData rdata; 55 TR_RemoteData rdata;
57 TR_Socket remote = TR_new(TR_UdpSocket, this->log, NULL, 0, 0); 56 TR_Socket remote = TR_new(TR_UdpSocket, this->log, NULL, 0, 0);
58 57
  58 + size = size>TR_UDP_MAX_READ_BLOCK ? TR_UDP_MAX_READ_BLOCK : size;
  59 +
  60 + unsigned char buffer[size];
  61 +
59 remote->addrlen = this->addrlen; 62 remote->addrlen = this->addrlen;
60 63
61 received = recvfrom( 64 received = recvfrom(
Please register or login to post a comment