• Philip Withnall's avatar
    agent: Add support for vectored I/O for receives · 253be348
    Philip Withnall authored
    Add two new public functions:
     • nice_agent_recv_messages()
     • nice_agent_recv_messages_nonblocking()
    which allow receiving multiple messages in a single call, and support
    vectors of buffers to receive the messages into.
    The existing nice_agent_recv[_nonblocking]() APIs have been left
    This tidies up a lot of the message handling code internally, and
    eliminates a couple of memcpy()s. There are still a few more memcpy()s
    on the critical path, which could be eliminated with further work.
    In the reliable agent case, every message is memcpy()ed twice: once into
    the pseudo-TCP receive buffer, and once out of it. The copy on input
    could be eliminated (in the case of in-order delivery of packets) by
    receiving directly into the receive buffer. The copy on output can’t be
    eliminated except in the I/O callback case (when
    nice_agent_attach_recv() has been used), in which case the callback
    could be invoked with a pointer directly into the pseudo-TCP receive
    In the non-reliable agent case, zero memcpy()s are used.
    A couple of the more complex socket implementations (TURN and HTTP) have
    slow paths during setup, and partially also during normal use. These
    could be optimised further, and FIXME comments have been added.
agent-priv.h 7.9 KB