GNOME Bugzilla – Bug 774520
GSocket allocates and processes control messages even if not requested
Last modified: 2016-11-20 16:11:12 UTC
If g_socket_receive_message_with_timeout() is called with messages == NULL a 2048 byte buffer for control messages is still allocated in input_message_to_msghdr() and the control messages are de-serialized and disposed in input_message_from_msghdr(). This is redundant and causes extra load at high packet rate. Unfortunately the manpage of recvmsg isn't very specific about the minimum size of msg_control and if msg_control can be NULL. But I think we could set msg_controllen to 0 and the whole above mentioned processing would be bypassed.
Created attachment 340012 [details] [review] Patch to completely bypass the control message processing
(In reply to Petr Kulhavy from comment #0) > Unfortunately the manpage of recvmsg isn't very specific about the minimum > size of msg_control and if msg_control can be NULL. But I think we could set > msg_controllen to 0 and the whole above mentioned processing would be > bypassed. Actually, I think it is pretty clear: if msg_controllen isn't large enough, then the control messages are discarded and MSG_CTRUNC is set in msg->msg_flags. So this is fine. Pushed with indentation fixes. Thanks for the patch.