Commit be9f046b authored by Olivier Crête's avatar Olivier Crête

SPECIFIC: pseudotcp: Limit to 3 buffers every 10ms

This should help prevent filling up UDP sockets when multiple
pseudotcp connections are over the same tunnel.
parent b3221c12
......@@ -3165,12 +3165,29 @@ transmit(PseudoTcpSocket *self, SSegment *segment, guint32 now)
return 0;
}
static gboolean
send_again (gpointer data)
{
PseudoTcpSocket *self = data;
g_rec_mutex_lock (&self->priv->mutex);
if (self->priv->state < TCP_LAST_ACK)
attempt_send(self, sfNone);
g_rec_mutex_unlock (&self->priv->mutex);
return G_SOURCE_REMOVE;
}
static void
attempt_send(PseudoTcpSocket *self, SendFlags sflags)
{
PseudoTcpSocketPrivate *priv = self->priv;
guint32 now = get_current_time (self);
gboolean bFirst = TRUE;
guint count = 0;
#if 0
DEBUG (PSEUDO_TCP_DEBUG_NORMAL, "Attempting send with flags %u.", sflags);
......@@ -3275,6 +3292,7 @@ attempt_send(PseudoTcpSocket *self, SendFlags sflags)
}
transmit_status = transmit(self, sseg, now);
count++;
if (transmit_status != 0) {
DEBUG (PSEUDO_TCP_DEBUG_NORMAL, "transmit failed");
......@@ -3283,6 +3301,19 @@ attempt_send(PseudoTcpSocket *self, SendFlags sflags)
return;
}
if (count > 3) {
GSource *src;
src = g_timeout_source_new (10);
g_source_set_name (src, "Pseudo-TCP send continue");
g_source_set_callback (src, send_again, g_object_ref(self),
g_object_unref);
g_source_set_priority (src, 250);
g_source_attach (src, priv->main_context);
g_source_unref (src);
return;
}
if (sflags == sfImmediateAck || sflags == sfDelayedAck)
sflags = sfNone;
}
......
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