Commit 5aa49920 authored by Jakub Adam's avatar Jakub Adam

udp-turn: don't re-iterate incoming TURN control messages

After being parsed, a TURN control message turns into a NiceInputMessage
with zero length. Such message doesn't increment the iteration counter i
and so is re-processed in the next iteration, which detects right away
that message->length == 0 and continues to the next element in
recv_messages.

Thus, n_valid_messages variable serves no real purpose and to achieve
the same result we can simply increment the iteration counter after each
message.
parent 67771ba2
......@@ -340,7 +340,6 @@ socket_recv_messages (NiceSocket *sock,
gint n_messages;
guint i;
gboolean error = FALSE;
guint n_valid_messages;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
......@@ -360,7 +359,7 @@ socket_recv_messages (NiceSocket *sock,
* Implementing such a path means rewriting the TURN parser (and hence the
* STUN message code) to operate on vectors of buffers, rather than a
* monolithic buffer. */
for (i = 0; i < (guint) n_messages; i += n_valid_messages) {
for (i = 0; i < (guint) n_messages; ++i) {
NiceInputMessage *message = &recv_messages[i];
NiceSocket *dummy;
NiceAddress from;
......@@ -369,8 +368,6 @@ socket_recv_messages (NiceSocket *sock,
gint parsed_buffer_length;
gboolean allocated_buffer = FALSE;
n_valid_messages = 1;
if (message->length == 0)
continue;
......@@ -397,13 +394,11 @@ socket_recv_messages (NiceSocket *sock,
if (parsed_buffer_length < 0) {
error = TRUE;
} else if (parsed_buffer_length == 0) {
/* A TURN control message which needs ignoring. Re-use this
* NiceInputMessage in the next loop iteration. */
n_valid_messages = 0;
} else {
} else if (parsed_buffer_length > 0) {
*message->from = from;
}
/* parsed_buffer_length == 0 means this is a TURN control message which
* needs ignoring. */
/* Split up the monolithic buffer again into the caller-provided buffers. */
if (parsed_buffer_length > 0 && allocated_buffer) {
......
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