Refactored UDP socket_send_messages to use g_socket_send_messages
This request tries to address what I introduced in #117 (closed).
First of all, it collapses the static socket_send_message
and socket_send_messages
methods in udp-bsd.c
in a single method, which means there now only is socket_send_messages
(which is the one that is exported to the libnice core). In fact, they would have shared a lot of code anyway, and so the method internally decides which GIO socket primitive to use depending on the number of messages it's trying to push:
- if
n_messages
is1
, then it usesg_socket_send_message
, which means the method is equivalent to what the code did before insocket_send_message
; - if
n_messages
higher than1
, it means we're trying to send more than one message at the same time, and so we prepare aGOutputMessage
array and pass it tog_socket_send_messages
, which as I said in #117 (closed) internally usessendmmsg
if the platform supports it.
Everything should be exactly the same in term of APIs and what is returned: it's just an internal change on how to deal with multiple messages, so hopefully it doesn't break anything. The tests seem to work fine as well, with the exception of test-bsd
(but that may be because I'm on Linux and not BSD?). In particular, I've checked test-send-recv
, since I've noticed it does use nice_agent_send_messages_nonblocking
to send a bunch of messages together, and that seems to work as expected.
That said, I've added the WIP:
prefix to the merge request to be sure I'm not doing anything wrong, since I'm not 100% familiar on the internals. Next step on my end is to work on a branch in Janus to use nice_agent_send_messages_nonblocking
instead of nice_agent_send
, and then do some performance assessment to verify whether or not this patch helps.
Looking forward to your feedback!