1. 31 Mar, 2014 1 commit
  2. 07 Mar, 2014 1 commit
  3. 06 Mar, 2014 1 commit
  4. 04 Mar, 2014 1 commit
    • Philip Withnall's avatar
      agent: Fix a potential re-entrancy situation · e62d47d6
      Philip Withnall authored
      If we emit signals from component_io_cb() in the middle of a read, it’s
      possible that one of those signals will be picked up by the client to
      perform another read. A likely candidate (and what was triggering the
      re-entrancy here) would be component-state-changed. Since signals are
      emitted synchronously, the second read would being inside the first, and
      trigger the anti-re-entrancy assertion.
      e62d47d6
  5. 25 Feb, 2014 1 commit
  6. 24 Feb, 2014 5 commits
  7. 21 Feb, 2014 1 commit
  8. 20 Feb, 2014 1 commit
  9. 19 Feb, 2014 1 commit
  10. 13 Feb, 2014 1 commit
  11. 31 Jan, 2014 26 commits
    • Olivier Crête's avatar
      agent: Remove weak pointers, they aren't thread safe anyway · faa90dda
      Olivier Crête authored
      And we get close to 10% perf boost
      faa90dda
    • Olivier Crête's avatar
    • Olivier Crête's avatar
      agent: Restore the ability nice_agent_send() to send partial buffers · 919b2c46
      Olivier Crête authored
      This is very important for reliable mode.
      
      Also use it in the GOutputStream so as to not get into the case where
      there is still some space in the TCP buffer, but not enough for one message.
      Also warn against this problem.
      919b2c46
    • Olivier Crête's avatar
      agent: Replace nice_agent_build_io_stream() with nice_agent_get_io_stream() · 430e8db5
      Olivier Crête authored
      Also made the GIOStream into a singleton, it always returns the same one.
      Also make it impossible to create a GIOStream for a non-existing stream/component
      430e8db5
    • Olivier Crête's avatar
      Remove the "length" parameter from NiceOutputMessage · 4f456a46
      Olivier Crête authored
      It was used correctly only half the time anyway
      4f456a46
    • Olivier Crête's avatar
      Remove the "to" parameter from NiceOutputMessage · 5c235a86
      Olivier Crête authored
      We never send multiple messages to separate targets in practice, so
      this will simplify the code
      5c235a86
    • Olivier Crête's avatar
      agent: Attaching to a NULL context should attach to the default one · a5c8a141
      Olivier Crête authored
      Otherwise it would have attached to a newly created context
      a5c8a141
    • Philip Withnall's avatar
      agent: Add support for vectored I/O for sends · f7b15f14
      Philip Withnall authored
      Add one new public function, nice_agent_send_messages_nonblocking(),
      which replaces nice_agent_send_full(). This isn’t an API break, because
      nice_agent_send_full() hasn’t been in a release yet. The new API allows
      sending multiple messages in a single call, and supports vectors of
      buffers to transmit the messages from.
      
      The existing nice_agent_send() API has been left untouched, although
      it’s a bit of a bugbear because it’s non-blocking and doesn’t fit with
      the new *_nonblocking() naming scheme. Oh well.
      
      This doesn’t bring any notable changes to the number of memcpy()s on the
      critical path: it remains at zero for the common cases and common socket
      types. It introduces the possibility for future work to eliminate some
      memcpy()s in more complex socket types, like tcp-turn and tcp-bsd, but
      these optimisations have not been made yet. FIXME comments have been
      added.
      
      This includes modifications to the test-send-recv unit test to cover the
      new API.
      f7b15f14
    • Philip Withnall's avatar
      socket: Add vectored I/O support for sending on sockets · 515481e6
      Philip Withnall authored
      Replace the send() API with a send_messages() API, which supports
      sending multiple messages, each with multiple buffers rather than a
      single monolithic buffer.
      
      This doesn’t break API, as the socket API is not exposed outside
      libnice. It does introduce a new struct: NiceOutputMessage, which is
      analogous to struct mmsghdr and NiceInputMessage.
      
      This includes updates to the test-bsd test to cover the changed API.
      
      The existing nice_socket_send() API has been retained as a thin wrapper
      around nice_socket_send_messages(), for convenience only. It’s hoped
      that internal usage of this API will decline to the point where it can
      be removed.
      515481e6
    • Philip Withnall's avatar
      agent: Move gtk-doc comments from agent.c to agent.h for new API · 55e53a9c
      Philip Withnall authored
      I completely disagree with this, and believe the C file is a much better
      place for them, as then they’re:
       • easier to read while hacking on the functions, and
       • easier to modify once finished hacking on the functions.
      
      I think the argument for putting them in the header files (so that the
      documentation is available by the function declarations) is weak, as the
      generated gtk-doc manual should be installed on the system alongside the
      header files in any case.
      55e53a9c
    • 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
      untouched.
      
      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
      buffer.
      
      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.
      253be348
    • Philip Withnall's avatar
      stun: Add a fast version of stun_message_validate_buffer_length() · e9ebf991
      Philip Withnall authored
      stun_message_validate_buffer_length() is already fast, but requires the
      entire message to be in a single monolithic buffer. For introducing
      vectored I/O, this becomes impossible to guarantee.
      
      Rather than rewriting the STUN code to natively support vectors of
      buffers (which would be a huge undertaking, and would probably slow
      the code down considerably), implement a fast check of whether a message
      is likely to be a STUN packet which *does* support vectored I/O. This
      can then be used to determine whether to compact the vector of buffers
      to a single monolithic one in order to validate the message more
      thoroughly.
      e9ebf991
    • Philip Withnall's avatar
      socket: Add vectored I/O support for receiving on sockets · dfab04cd
      Philip Withnall authored
      Replace the recv() API with a recv_messages() API, which supports
      receiving multiple messages, each with multiple buffers rather than a
      single monolithic buffer.
      
      This doesn’t break API, as the socket API is not exposed outside
      libnice. It does introduce a new struct: NiceInputMessage, which is
      analogous to struct mmsghdr.
      
      This includes updates to the test-bsd test to cover the changed API.
      dfab04cd
    • Philip Withnall's avatar
      agent: Simplify control flow in agent_recv_locked() · bc527dcf
      Philip Withnall authored
      This introduces no functional changes.
      bc527dcf
    • Olivier Crête's avatar
      agent: Make sure there is no integer overflow if the timeout is now · 69b876b3
      Olivier Crête authored
      Make sure that if the timeout is now, no negative number is passed as
      an unsigned
      69b876b3
    • Olivier Crête's avatar
      outputstream: Don't wake up on every input buffer · b5f79391
      Olivier Crête authored
      So instead of actually blocking on the FD, block on a GCancellable
      which is triggered when the writable callback is called. Also set the
      application's GCancellable as a child of this source.
      b5f79391
    • Olivier Crête's avatar
      agent: Only change pseudotcp clock if the new timeout is sooner · 83bcf954
      Olivier Crête authored
      Destroying and creating GSources is expensive, so also don't destroy and
      re-create if possible, instead lets use the new g_source_set_ready_time()
      83bcf954
    • Olivier Crête's avatar
    • Olivier Crête's avatar
      91befb1c
    • Olivier Crête's avatar
    • Philip Withnall's avatar
      agent: Queue incoming pseudo-TCP messages until ACKs can be sent · 18e2e3a2
      Philip Withnall authored
      If pseudo-TCP messages are received before a socket has been selected
      from all the STUN candidates, they would previously be immediately
      passed to the pseudo-TCP state machine, which would attempt to send ACKs
      for them. This would fail (due to a lack of an outbound UDP socket), and
      would incur a retransmit timeout in the TCP state machine. This slowed
      down the tests enormously if one agent in a test completed candidate
      selection before the other (which is an entirely reasonable scenario).
      
      This never occurred before because the existing tests artificially run
      both agents in lock-step, and never send data packets from one to the
      other until both have completed candidate selection. This is basically
      cheating.
      
      Fix the problem by queuing incoming pseudo-TCP messages until an
      outbound UDP socket is available to send the ACKs or SYNACKs on.
      18e2e3a2
    • Philip Withnall's avatar
      agent: Correct maximum UDP data length · d638586c
      Philip Withnall authored
      The maximum number of bytes in a UDP packet (ignoring problems like
      fragmentation and MTUs) is 65535 = 2^16-1 bytes, as the length field
      in the packet header is 16b wide.
      d638586c
    • Philip Withnall's avatar
      agent: Slightly improve debugging output · 7a05b330
      Philip Withnall authored
      7a05b330
    • Philip Withnall's avatar
      6b8039a2
    • Philip Withnall's avatar
      agent: Combine nice_agent_recv() and nice_agent_recv_nonblocking() · b560a86f
      Philip Withnall authored
      Sharing is caring.
      b560a86f
    • Philip Withnall's avatar
      agent: Add a nice_agent_recv_nonblocking() function · 6d3a32a0
      Philip Withnall authored
      This is a non-blocking variant of nice_agent_recv(), and will be used
      internally by the GPollableInputStream implementation. External
      implementations may use it as well.
      
      It reserves the right to iterate the main context, but doesn’t currently
      do so.
      6d3a32a0