Commit 43747431 authored by Petr Kulhavy's avatar Petr Kulhavy Committed by Dan Winship

GSocket: do not process control messages if not requested by the user

If g_socket_receive_message_with_timeout() is called with messages ==
NULL set the msg_control buffer to empty to not request the control
messages from recvmsg() at all.

This completely disables the control message processing and reduces
overhead, which might be critical at high packet rate.

https://bugzilla.gnome.org/show_bug.cgi?id=774520
parent 4ddaa891
......@@ -4099,8 +4099,16 @@ G_STMT_START { \
} \
\
/* control */ \
_msg->msg_controllen = 2048; \
_msg->msg_control = g_alloca (_msg->msg_controllen); \
if (_message->control_messages == NULL) \
{ \
_msg->msg_controllen = 0; \
_msg->msg_control = NULL; \
} \
else \
{ \
_msg->msg_controllen = 2048; \
_msg->msg_control = g_alloca (_msg->msg_controllen); \
} \
\
/* flags */ \
_msg->msg_flags = _message->flags; \
......@@ -4125,6 +4133,7 @@ input_message_from_msghdr (const struct msghdr *msg,
if (msg->msg_controllen >= sizeof (struct cmsghdr))
{
g_assert (message->control_messages != NULL);
for (cmsg = CMSG_FIRSTHDR (msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR ((struct msghdr *) msg, cmsg))
......@@ -4140,19 +4149,9 @@ input_message_from_msghdr (const struct msghdr *msg,
deserialization code, so just continue */
continue;
if (message->control_messages == NULL)
{
/* we have to do it this way if the user ignores the
* messages so that we will close any received fds.
*/
g_object_unref (control_message);
}
else
{
if (my_messages == NULL)
my_messages = g_ptr_array_new ();
g_ptr_array_add (my_messages, control_message);
}
if (my_messages == NULL)
my_messages = g_ptr_array_new ();
g_ptr_array_add (my_messages, control_message);
}
}
......
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