Commit 3774f539 authored by Olivier Crête's avatar Olivier Crête

SPECIFIC: pseudotcp: Set max buffer size to 64k

parent 60d2eed7
......@@ -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 (64 * 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;
......@@ -3542,13 +3570,13 @@ pseudo_tcp_socket_get_available_send_space (PseudoTcpSocket *self)
* precisely equivalent to state TCP_ESTABLISHED. It is also disabled while
* still in states TCP_LISTEN, TCP_SYN_SENT or TCP_SYN_RECEIVED. */
if (priv->state != TCP_ESTABLISHED ||
pseudo_tcp_fifo_get_write_remaining (&priv->sbuf) == 0) {
get_real_send_available (self) == 0) {
priv->bWriteEnable = TRUE;
ret = 0;
goto done;
}
ret = pseudo_tcp_fifo_get_write_remaining (&priv->sbuf);
ret = get_real_send_available (self);
done:
g_rec_mutex_unlock (&priv->mutex);
......
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