Commit 52ce33b6 authored by Olivier Crête's avatar Olivier Crête
Browse files

NOMERGE: pseudotcp: Set max buffer size to 128k

parent a72aa1fd
......@@ -174,6 +174,7 @@ const guint16 PACKET_MAXIMUMS[] = {
#define DEFAULT_RCV_BUF_SIZE (60 * 1024)
#define DEFAULT_SND_BUF_SIZE (90 * 1024)
#define MAX_BUFFER (128 * 1024)
/* Retransmission limits for a single segment. RFC 1122, §4.2.3.5. */
#define DEFAULT_RETRIES1 10 /* SHOULD correspond to at least 3 */
......@@ -1950,6 +1951,32 @@ done:
return retval;
}
static gsize
get_real_send_available (PseudoTcpSocket *self)
{
PseudoTcpSocketPrivate *priv = self->priv;
guint nInFlight;
gsize available_space;
gsize buffered;
available_space = pseudo_tcp_fifo_get_write_remaining (&priv->sbuf);
buffered = pseudo_tcp_fifo_get_buffered (&priv->sbuf);
nInFlight = priv->snd_nxt - priv->snd_una;
if (buffered > nInFlight)
buffered -= nInFlight;
else
buffered = 0;
if (buffered > MAX_BUFFER)
available_space = 0;
available_space = min (available_space, MAX_BUFFER - buffered);
return available_space;
}
gint
pseudo_tcp_socket_send(PseudoTcpSocket *self, const char * buffer, guint32 len)
{
......@@ -1966,7 +1993,7 @@ pseudo_tcp_socket_send(PseudoTcpSocket *self, const char * buffer, guint32 len)
goto done;
}
available_space = pseudo_tcp_fifo_get_write_remaining (&priv->sbuf);
available_space = get_real_send_available (self);
if (!available_space) {
priv->bWriteEnable = TRUE;
......@@ -2191,7 +2218,8 @@ queue (PseudoTcpSocket *self, const gchar * data, guint32 len, TcpFlags flags)
gsize available_space;
guint32 retval;
available_space = pseudo_tcp_fifo_get_write_remaining (&priv->sbuf);
available_space = get_real_send_available (self);
if (len > available_space) {
g_assert (flags == FLAG_NONE);
len = available_space;
......@@ -3512,7 +3540,7 @@ pseudo_tcp_socket_get_available_send_space (PseudoTcpSocket *self)
g_rec_mutex_lock (&priv->mutex);
if (!pseudo_tcp_state_has_sent_fin (priv->state)) {
ret = pseudo_tcp_fifo_get_write_remaining (&priv->sbuf);
ret = get_real_send_available (self);
} else {
ret = 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment