Use a different packet size
== DETAILS We had some disagreement on what packet size to use. The maximum packet size varies depending on the actual network hardware in use; the typical Ethernet value is relatively safe, but not 100% compatible. RFC 791 does, however, define a minimum datagram size that all IP hosts must be able to handle--and it's large enough for our needs, since we're generally not writing more than maybe 100 bytes at a time anyway. I also did a little bit of cleanup for readability.
This commit is contained in:
parent
23f0a85446
commit
5b3dd70ac3
|
@ -589,6 +589,11 @@ void net_print_exp(const char *str)
|
||||||
sendto(wiiu_log_socket, str, strlen(str), 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
|
sendto(wiiu_log_socket, str, strlen(str), 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* RFC 791 specifies that any IP host must be able to receive a datagram of 576 bytes.
|
||||||
|
* Since we're generally never logging more than a line or two's worth of data (~100 bytes)
|
||||||
|
* this is a reasonable size for our use. */
|
||||||
|
#define DGRAM_SIZE 576
|
||||||
|
|
||||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
||||||
{
|
{
|
||||||
if( wiiu_log_socket < 0)
|
if( wiiu_log_socket < 0)
|
||||||
|
@ -599,19 +604,19 @@ static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_
|
||||||
|
|
||||||
wiiu_log_lock = 1;
|
wiiu_log_lock = 1;
|
||||||
|
|
||||||
int ret;
|
int sent;
|
||||||
int remaining = len;
|
int remaining = len;
|
||||||
|
|
||||||
while(remaining > 0)
|
while(remaining > 0)
|
||||||
{
|
{
|
||||||
int block = remaining < 1472 ? remaining : 1472;
|
int block = remaining < DGRAM_SIZE ? remaining : DGRAM_SIZE;
|
||||||
ret = sendto(wiiu_log_socket, ptr, block, 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
|
sent = sendto(wiiu_log_socket, ptr, block, 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
|
||||||
|
|
||||||
if(ret < 0)
|
if(sent < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
remaining -= ret;
|
remaining -= sent;
|
||||||
ptr += ret;
|
ptr += sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
wiiu_log_lock = 0;
|
wiiu_log_lock = 0;
|
||||||
|
|
Loading…
Reference in New Issue