platform/upstream/libnice.git
10 years agocomponent: Set dummy callback from cancellable GSource
Olivier Crête [Fri, 28 Mar 2014 21:38:01 +0000 (17:38 -0400)]
component: Set dummy callback from cancellable GSource

10 years agoagent: Make it possible to set the relays after gathering
Olivier Crête [Fri, 28 Mar 2014 01:10:33 +0000 (21:10 -0400)]
agent: Make it possible to set the relays after gathering

This allows finding the relays asynchronously while trying to connect
with other methods.

10 years agoagent: Prevent nice_agent_set_port_range() from being called after a gather
Olivier Crête [Fri, 28 Mar 2014 01:10:02 +0000 (21:10 -0400)]
agent: Prevent nice_agent_set_port_range() from being called after a gather

The port range is only used when gathering, print a critical if it is
called afterwards as it will have no effect.

10 years agoagent: Prevent gather from being called multiple times
Olivier Crête [Fri, 28 Mar 2014 01:09:15 +0000 (21:09 -0400)]
agent: Prevent gather from being called multiple times

This can cause odd behaviors as it is not a idempotent function.

10 years agoagent: Refactor nice_agent_set_relay_info()
Olivier Crête [Fri, 28 Mar 2014 01:06:55 +0000 (21:06 -0400)]
agent: Refactor nice_agent_set_relay_info()

No behavior change is introduced

10 years agoturn: Put timeouts on the specific main context
Olivier Crête [Fri, 28 Mar 2014 00:13:55 +0000 (20:13 -0400)]
turn: Put timeouts on the specific main context

10 years agoturn: Don't try to process empty messages
Olivier Crête [Thu, 27 Mar 2014 21:55:31 +0000 (17:55 -0400)]
turn: Don't try to process empty messages

10 years agoagent: Bail out early on empty message
Olivier Crête [Thu, 27 Mar 2014 21:55:01 +0000 (17:55 -0400)]
agent: Bail out early on empty message

This can happen if a lower layer has consumed the message, bail out earlier in
that case.

10 years agoagent: Don't overwrite the size of the GInputBuffer, only set the global size
Olivier Crête [Thu, 27 Mar 2014 21:54:00 +0000 (17:54 -0400)]
agent: Don't overwrite the size of the GInputBuffer, only set the global size

10 years agopseudotcp: Also accept NiceInputMessage array with a single message
Olivier Crête [Thu, 27 Mar 2014 21:51:03 +0000 (17:51 -0400)]
pseudotcp: Also accept NiceInputMessage array with a single message

10 years agotest-fullmode: Don't use gmainloop when not required
Olivier Crête [Thu, 27 Mar 2014 21:50:31 +0000 (17:50 -0400)]
test-fullmode: Don't use gmainloop when not required

There are more than one callback that could stop it

10 years agotest-fullmode: Do #if instead of #ifdef as we set it to 0
Olivier Crête [Thu, 27 Mar 2014 21:50:08 +0000 (17:50 -0400)]
test-fullmode: Do #if instead of #ifdef as we set it to 0

10 years agotest-fullmode: Only wait for data on component 1
Olivier Crête [Thu, 27 Mar 2014 21:49:43 +0000 (17:49 -0400)]
test-fullmode: Only wait for data on component 1

10 years agotcp-bsd: Use default main context if none specified
Olivier Crête [Thu, 27 Mar 2014 16:33:23 +0000 (12:33 -0400)]
tcp-bsd: Use default main context if none specified

10 years agoturn-tcp: Don't corrupt messages
Olivier Crête [Thu, 27 Mar 2014 07:54:32 +0000 (03:54 -0400)]
turn-tcp: Don't corrupt messages

10 years agoagent: Free every parameter
Olivier Crête [Sat, 15 Mar 2014 03:53:06 +0000 (23:53 -0400)]
agent: Free every parameter

Fixes off-by-one error

10 years agoagent: Create a custom pointer GType to recognize the stream ids
Olivier Crête [Sat, 15 Mar 2014 03:52:45 +0000 (23:52 -0400)]
agent: Create a custom pointer GType to recognize the stream ids

10 years agoagent: Improve documentation for NiceAgent::new-candidate
Philip Withnall [Fri, 7 Mar 2014 09:18:04 +0000 (09:18 +0000)]
agent: Improve documentation for NiceAgent::new-candidate

Note that it’s a new _local_ candidate.

10 years agoNEWS: Remove superfluous empty lines
Olivier Crête [Fri, 7 Mar 2014 02:38:07 +0000 (21:38 -0500)]
NEWS: Remove superfluous empty lines

10 years agoVersion 0.1.5.1
Olivier Crête [Fri, 7 Mar 2014 02:30:26 +0000 (21:30 -0500)]
Version 0.1.5.1

10 years agoVersion 0.1.5 0.1.5
Olivier Crête [Fri, 7 Mar 2014 02:21:37 +0000 (21:21 -0500)]
Version 0.1.5

10 years agoconfigure: Remove -Wunsafe-loop-optimizations, it causes false warnings
Olivier Crête [Fri, 7 Mar 2014 01:51:23 +0000 (20:51 -0500)]
configure: Remove -Wunsafe-loop-optimizations, it causes false warnings

10 years agotests: Add private header to tarball
Olivier Crête [Fri, 7 Mar 2014 01:45:43 +0000 (20:45 -0500)]
tests: Add private header to tarball

10 years agotests: Don't verify the message content with not in reliable mode, because its unreliable
Olivier Crête [Fri, 7 Mar 2014 01:00:38 +0000 (20:00 -0500)]
tests: Don't verify the message content with not in reliable mode, because its unreliable

10 years agoagent: Enforce limits on the size buffers, because the retval is signed
Olivier Crête [Fri, 7 Mar 2014 00:59:45 +0000 (19:59 -0500)]
agent: Enforce limits on the size buffers, because the retval is signed

10 years agodoc: Update doc generation
Olivier Crête [Thu, 6 Mar 2014 22:06:16 +0000 (17:06 -0500)]
doc: Update doc generation

10 years agoiostream: De-gtkdoc the comments, as it's not public API
Olivier Crête [Thu, 6 Mar 2014 22:06:06 +0000 (17:06 -0500)]
iostream: De-gtkdoc the comments, as it's not public API

10 years agoagent: Remove unused #include
Philip Withnall [Thu, 6 Mar 2014 16:00:07 +0000 (16:00 +0000)]
agent: Remove unused #include

net/if_arp.h doesn’t exist on OS X, and hence causes cross-compilation
to fail. It doesn’t appear to be needed for any of the functions
currently used in interfaces.c anyway.

10 years agoagent: Ensure the pending signal queue is cleared on dispose
Philip Withnall [Wed, 5 Mar 2014 10:45:00 +0000 (10:45 +0000)]
agent: Ensure the pending signal queue is cleared on dispose

10 years agoagent: Fix a potential re-entrancy situation
Philip Withnall [Tue, 4 Mar 2014 13:48:03 +0000 (13:48 +0000)]
agent: Fix a potential re-entrancy situation

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.

10 years agotests: Use dynamically allocated port for test-new-dribble
Olivier Crête [Tue, 25 Feb 2014 05:48:56 +0000 (00:48 -0500)]
tests: Use dynamically allocated port for test-new-dribble

10 years agotests: Fix horribly raciness in test-new-dribble
Olivier Crête [Tue, 25 Feb 2014 05:23:47 +0000 (00:23 -0500)]
tests: Fix horribly raciness in test-new-dribble

10 years agotests: Split racy "closing" into a test for stopping while reading or writing
Olivier Crête [Tue, 25 Feb 2014 04:05:44 +0000 (23:05 -0500)]
tests: Split racy "closing" into a test for stopping while reading or writing

We wan't to make sure not to have a race where a thread blocks in a blocking
receive or send while nice_agent_remove_stream() is called

10 years agotest: Use a less racy way to know if the test is ready to start
Olivier Crête [Tue, 25 Feb 2014 04:03:42 +0000 (23:03 -0500)]
test: Use a less racy way to know if the test is ready to start

Also, keep a pointer to the other structure for tests to use

10 years agooutputstream: Add a cancellable to get out of blocking write if the stream is removed
Olivier Crête [Tue, 25 Feb 2014 04:02:39 +0000 (23:02 -0500)]
outputstream: Add a cancellable to get out of blocking write if the stream is removed

10 years agocomponent: Add a GCancellable to get of out blocking nice_agent_recv()
Olivier Crête [Tue, 25 Feb 2014 04:02:04 +0000 (23:02 -0500)]
component: Add a GCancellable to get of out blocking nice_agent_recv()

Otherwise, it may be stuck iterating the context forever if all of the
other sources are gone.

10 years agocomponent: Keep its own context at all times
Olivier Crête [Tue, 25 Feb 2014 04:00:33 +0000 (23:00 -0500)]
component: Keep its own context at all times

Don't re-create it.

10 years agoIgnore .trs and .log file from newer automake
Olivier Crête [Mon, 24 Feb 2014 23:59:39 +0000 (18:59 -0500)]
Ignore .trs and .log file from newer automake

10 years agoagent: Delay signal emission after the lock has been released
Olivier Crête [Mon, 24 Feb 2014 23:50:59 +0000 (18:50 -0500)]
agent: Delay signal emission after the lock has been released

This way, there can be no annoying re-entrancy in our code.

10 years agoagent: Replace recursive mutex with non-recursive
Olivier Crête [Mon, 24 Feb 2014 23:51:31 +0000 (18:51 -0500)]
agent: Replace recursive mutex with non-recursive

This should prevent us from re-adding re-entrancy in the future

10 years agoagent: Delay signal emission after the lock has been released
Olivier Crête [Mon, 24 Feb 2014 23:50:59 +0000 (18:50 -0500)]
agent: Delay signal emission after the lock has been released

This way, there can be no annoying re-entrancy in our code.

10 years agoiostream: remove re-entrant call into NiceAgent
Olivier Crête [Mon, 24 Feb 2014 22:25:50 +0000 (17:25 -0500)]
iostream: remove re-entrant call into NiceAgent

10 years agooutputstream: If tcp, only check for space in the PseudoTCP queue
Olivier Crête [Mon, 24 Feb 2014 23:39:21 +0000 (18:39 -0500)]
outputstream: If tcp, only check for space in the PseudoTCP queue

10 years agoagent: Expand documentation for a couple of NiceAgent functions
Philip Withnall [Tue, 11 Feb 2014 10:01:18 +0000 (10:01 +0000)]
agent: Expand documentation for a couple of NiceAgent functions

Expand documentation for nice_agent_gather_candidates() and
nice_agent_set_remote_credentials().

10 years agoagent: Fix inlining of nice_debug() if NDEBUG is defined
Philip Withnall [Fri, 31 Jan 2014 11:52:15 +0000 (11:52 +0000)]
agent: Fix inlining of nice_debug() if NDEBUG is defined

10 years agoagent: Assert on re-entrant reads
Philip Withnall [Fri, 31 Jan 2014 11:43:19 +0000 (11:43 +0000)]
agent: Assert on re-entrant reads

Ensure the agent’s context doesn’t get iterated while in the middle of
reading a message, as that will corrupt the component->recv_messages
state.

10 years agoagent: Improve debug output
Philip Withnall [Fri, 31 Jan 2014 11:43:03 +0000 (11:43 +0000)]
agent: Improve debug output

10 years agoagent: Add nice_input_message_iter_compare()
Philip Withnall [Fri, 31 Jan 2014 11:42:16 +0000 (11:42 +0000)]
agent: Add nice_input_message_iter_compare()

Use it instead of memcmp() to avoid comparing padding bytes.

10 years agodocs: Remove NiceIOStream, nothing specific to document
Olivier Crête [Fri, 21 Feb 2014 20:05:59 +0000 (15:05 -0500)]
docs: Remove NiceIOStream, nothing specific to document

10 years agoagent: returning 0 valid messages is valid, it means EOF
Olivier Crête [Fri, 21 Feb 2014 19:34:28 +0000 (14:34 -0500)]
agent: returning 0 valid messages is valid, it means EOF

10 years agoiostream: iostreams are only for reliable streams, no need to check
Olivier Crête [Thu, 20 Feb 2014 06:41:22 +0000 (01:41 -0500)]
iostream: iostreams are only for reliable streams, no need to check

10 years agoagent: Use locally allocated memory if the application buffer is not big enough for...
Olivier Crête [Thu, 20 Feb 2014 06:40:30 +0000 (01:40 -0500)]
agent: Use locally allocated memory if the application buffer is not big enough for one STUN packet

10 years agooutputstream: Trigger the pollable source on error or removal
Olivier Crête [Wed, 19 Feb 2014 04:52:37 +0000 (23:52 -0500)]
outputstream: Trigger the pollable source on error or removal

10 years agoagent: Fix compiler warnings
Olivier Crête [Thu, 13 Feb 2014 20:14:23 +0000 (15:14 -0500)]
agent: Fix compiler warnings

10 years agoconfigure: Add newline ignoring
Olivier Crête [Wed, 5 Feb 2014 23:16:02 +0000 (18:16 -0500)]
configure: Add newline ignoring

Otherwise it ran the "yes" command

10 years agoconfigure: Move -Werror=unsafe-loop-optimizations to the maximum level
Olivier Crête [Wed, 5 Feb 2014 02:29:04 +0000 (21:29 -0500)]
configure: Move -Werror=unsafe-loop-optimizations to the maximum level

It tends to cause false warnings

10 years agopseudotcp: Remove one duplicated call to g_get_monotonic_time()
Olivier Crête [Fri, 31 Jan 2014 06:25:57 +0000 (01:25 -0500)]
pseudotcp: Remove one duplicated call to g_get_monotonic_time()

10 years agoagent: Remove weak pointers, they aren't thread safe anyway
Olivier Crête [Fri, 31 Jan 2014 06:06:08 +0000 (01:06 -0500)]
agent: Remove weak pointers, they aren't thread safe anyway

And we get close to 10% perf boost

10 years agopseudotcp: Add list of unsent segment
Olivier Crête [Fri, 31 Jan 2014 05:18:15 +0000 (00:18 -0500)]
pseudotcp: Add list of unsent segment

Looping through the list of send segment was the only thing from libnice
showing up in my profiler. Keeping a list of segment that were never sent
has made it disappear.

10 years agoagent: Avoid calling nice_address_to_string() when debugging is disabled
Olivier Crête [Fri, 31 Jan 2014 05:11:04 +0000 (00:11 -0500)]
agent: Avoid calling nice_address_to_string() when debugging is disabled

10 years agopseudotcp: Use GQueue for list that has stuff inserted in the end
Olivier Crête [Fri, 31 Jan 2014 04:33:16 +0000 (23:33 -0500)]
pseudotcp: Use GQueue for list that has stuff inserted in the end

10 years agopseudotcp: Don't change the receive buffer size if it hasnt changed
Olivier Crête [Fri, 31 Jan 2014 04:08:36 +0000 (23:08 -0500)]
pseudotcp: Don't change the receive buffer size if it hasnt changed

10 years agoagent: Restore the ability nice_agent_send() to send partial buffers
Olivier Crête [Fri, 31 Jan 2014 03:06:32 +0000 (22:06 -0500)]
agent: Restore the ability nice_agent_send() to send partial buffers

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.

10 years agoagent: Replace nice_agent_build_io_stream() with nice_agent_get_io_stream()
Olivier Crête [Fri, 31 Jan 2014 02:59:33 +0000 (21:59 -0500)]
agent: Replace nice_agent_build_io_stream() with nice_agent_get_io_stream()

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

10 years agoRemove the "length" parameter from NiceOutputMessage
Olivier Crête [Fri, 31 Jan 2014 02:21:13 +0000 (21:21 -0500)]
Remove the "length" parameter from NiceOutputMessage

It was used correctly only half the time anyway

10 years agoRemove the "to" parameter from NiceOutputMessage
Olivier Crête [Fri, 31 Jan 2014 01:38:15 +0000 (20:38 -0500)]
Remove the "to" parameter from NiceOutputMessage

We never send multiple messages to separate targets in practice, so
this will simplify the code

10 years agoagent: Attaching to a NULL context should attach to the default one
Olivier Crête [Thu, 30 Jan 2014 23:37:25 +0000 (18:37 -0500)]
agent: Attaching to a NULL context should attach to the default one

Otherwise it would have attached to a newly created context

10 years agosocket: Add note that the packet dropping in tcp-bsd is broken behavior
Olivier Crête [Fri, 24 Jan 2014 08:02:38 +0000 (03:02 -0500)]
socket: Add note that the packet dropping in tcp-bsd is broken behavior

10 years agotests: Fix test-restart to only quit on state changes
Philip Withnall [Wed, 22 Jan 2014 12:36:33 +0000 (12:36 +0000)]
tests: Fix test-restart to only quit on state changes

Previously, there was a race between receiving the data packets and
changing state to READY, which would cause one of the final assertions
to fail.

10 years agoagent: Add support for vectored I/O for sends
Philip Withnall [Tue, 21 Jan 2014 15:56:18 +0000 (15:56 +0000)]
agent: Add support for vectored I/O for sends

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.

10 years agosocket: Add vectored I/O support for sending on sockets
Philip Withnall [Mon, 20 Jan 2014 07:56:47 +0000 (07:56 +0000)]
socket: Add vectored I/O support for sending on sockets

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.

10 years agoagent: Move gtk-doc comments from agent.c to agent.h for new API
Philip Withnall [Tue, 21 Jan 2014 10:50:19 +0000 (10:50 +0000)]
agent: Move gtk-doc comments from agent.c to agent.h for new API

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.

10 years agotests: Update test-send-recv to support vectored I/O
Philip Withnall [Thu, 16 Jan 2014 16:11:25 +0000 (16:11 +0000)]
tests: Update test-send-recv to support vectored I/O

10 years agoagent: Add support for vectored I/O for receives
Philip Withnall [Thu, 16 Jan 2014 16:06:30 +0000 (16:06 +0000)]
agent: Add support for vectored I/O for receives

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.

10 years agotests: Fix a shadowed function name in test-pseudotcp
Philip Withnall [Thu, 16 Jan 2014 16:05:12 +0000 (16:05 +0000)]
tests: Fix a shadowed function name in test-pseudotcp

The write() function already exists; we can’t re-define it as a
callback.

10 years agostun: Add a fast version of stun_message_validate_buffer_length()
Philip Withnall [Thu, 16 Jan 2014 16:02:07 +0000 (16:02 +0000)]
stun: Add a fast version of stun_message_validate_buffer_length()

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.

10 years agosocket: Fix the formal parameter types of nice_turn_socket_parse_recv()
Philip Withnall [Thu, 16 Jan 2014 16:00:42 +0000 (16:00 +0000)]
socket: Fix the formal parameter types of nice_turn_socket_parse_recv()

gsize and guint8 are more obviously for binary data than gint and gchar.

Note the signedness of the return type has changed: the function never
returns negative values.

10 years agosocket: Add vectored I/O support for receiving on sockets
Philip Withnall [Thu, 16 Jan 2014 15:45:12 +0000 (15:45 +0000)]
socket: Add vectored I/O support for receiving on sockets

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.

10 years agoagent: Simplify control flow in agent_recv_locked()
Philip Withnall [Wed, 15 Jan 2014 14:10:34 +0000 (14:10 +0000)]
agent: Simplify control flow in agent_recv_locked()

This introduces no functional changes.

10 years agostun: Use SHA1 iteration functions directly in HMAC calculation
Philip Withnall [Wed, 8 Jan 2014 08:26:41 +0000 (08:26 +0000)]
stun: Use SHA1 iteration functions directly in HMAC calculation

Rather than using an intermediate method which takes a vector of
buffers, just use the SHA1 iteration functions directly in the HMAC
calculations. This eliminates several cases where the vector of buffers
was of fixed length, and it was actually taking more code to set up and
pass the vector than it would have to call the iteration functions
directly.

10 years agooutputstream: Put GError in the right GError**
Olivier Crête [Fri, 31 Jan 2014 02:42:26 +0000 (21:42 -0500)]
outputstream: Put GError in the right GError**

10 years agocomponent: Don't free the nice socket before detaching it
Olivier Crête [Thu, 30 Jan 2014 23:19:19 +0000 (18:19 -0500)]
component: Don't free the nice socket before detaching it

10 years agoagent: Make sure there is no integer overflow if the timeout is now
Olivier Crête [Fri, 24 Jan 2014 07:01:29 +0000 (02:01 -0500)]
agent: Make sure there is no integer overflow if the timeout is now

Make sure that if the timeout is now, no negative number is passed as
an unsigned

10 years agopseudotcp: Don't fail when sending over 4GiB of data
Olivier Crête [Fri, 24 Jan 2014 06:55:18 +0000 (01:55 -0500)]
pseudotcp: Don't fail when sending over 4GiB of data

Integer comparisons need to take care of rollovers

10 years agooutputstream: Fix race between writable callback and GCond wait
Olivier Crête [Fri, 24 Jan 2014 06:14:23 +0000 (01:14 -0500)]
outputstream: Fix race between writable callback and GCond wait

10 years agoinputstream: Make the GSource hold a weak ref on the agent
Olivier Crête [Fri, 24 Jan 2014 05:53:56 +0000 (00:53 -0500)]
inputstream: Make the GSource hold a weak ref on the agent

This also means that it can't have the component ref. Also make the
cancellable a child source of this GPollableInputStream one

10 years agooutputstream: Don't wake up on every input buffer
Olivier Crête [Fri, 24 Jan 2014 05:52:01 +0000 (00:52 -0500)]
outputstream: Don't wake up on every input buffer

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.

10 years agoagent: Only change pseudotcp clock if the new timeout is sooner
Olivier Crête [Fri, 24 Jan 2014 04:48:14 +0000 (23:48 -0500)]
agent: Only change pseudotcp clock if the new timeout is sooner

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()

10 years agopseudotcp: Switch to using monotonic time
Olivier Crête [Fri, 24 Jan 2014 04:47:14 +0000 (23:47 -0500)]
pseudotcp: Switch to using monotonic time

10 years agooutputstream: Release blocking send lock while sending
Olivier Crête [Fri, 24 Jan 2014 02:37:43 +0000 (21:37 -0500)]
outputstream: Release blocking send lock while sending

Otherwise it produces a deadlock

10 years agooutputstream: Make the blocking send thread safe
Olivier Crête [Fri, 24 Jan 2014 02:03:46 +0000 (21:03 -0500)]
outputstream: Make the blocking send thread safe

There was a possible race between disconnection and freeing of the WriteDatas
structure, now it's ref-counted so it can never happen. Also set the len to -1
if the cancellable was cancelled.

10 years agoagent: Return G_IO_ERROR_WOULD_BLOCK for non-connected pseudoTCP
Olivier Crête [Fri, 24 Jan 2014 02:02:07 +0000 (21:02 -0500)]
agent: Return G_IO_ERROR_WOULD_BLOCK for non-connected pseudoTCP

10 years agoagent: Return cancelled if sending is cancelled
Olivier Crête [Fri, 24 Jan 2014 02:01:41 +0000 (21:01 -0500)]
agent: Return cancelled if sending is cancelled

10 years agonice: Add nice_agent_build_io_stream to exported symbols
Olivier Crête [Fri, 24 Jan 2014 00:35:27 +0000 (19:35 -0500)]
nice: Add nice_agent_build_io_stream to exported symbols

10 years agoagent: Queue incoming pseudo-TCP messages until ACKs can be sent
Philip Withnall [Tue, 21 Jan 2014 09:55:57 +0000 (09:55 +0000)]
agent: Queue incoming pseudo-TCP messages until ACKs can be sent

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.

10 years agoagent: Correct maximum UDP data length
Philip Withnall [Tue, 21 Jan 2014 09:51:29 +0000 (09:51 +0000)]
agent: Correct maximum UDP data length

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.

10 years agotests: Remove redundant GLIB_CHECK_VERSION checks
Philip Withnall [Mon, 20 Jan 2014 12:07:18 +0000 (12:07 +0000)]
tests: Remove redundant GLIB_CHECK_VERSION checks

Since we define GLIB_VERSION_MIN_REQUIRED, GLib will not emit deprecated
function call warnings for functions like g_type_init() or
g_thread_init().

10 years agoagent: Slightly improve debugging output
Philip Withnall [Tue, 14 Jan 2014 13:58:04 +0000 (13:58 +0000)]
agent: Slightly improve debugging output

10 years agoagent: Document correctness of io_mutex locking
Philip Withnall [Tue, 14 Jan 2014 10:00:14 +0000 (10:00 +0000)]
agent: Document correctness of io_mutex locking

10 years agoagent: Combine nice_agent_recv() and nice_agent_recv_nonblocking()
Philip Withnall [Tue, 14 Jan 2014 09:32:10 +0000 (09:32 +0000)]
agent: Combine nice_agent_recv() and nice_agent_recv_nonblocking()

Sharing is caring.