Philip Withnall [Wed, 16 Apr 2014 18:09:06 +0000 (19:09 +0100)]
agent: Fix leaks if a component is removed during a recv() call
If the error handling block in the middle of the recv() loop is hit,
various things were previously leaked (context, cancellable_source) and
the return values were potentially incorrect.
Fix the break out of the error handling block to clean up correctly.
Olivier Crête [Wed, 16 Apr 2014 03:18:21 +0000 (23:18 -0400)]
stun: Restore argument type to stun_usage_bind_process(), it's used outside libnice
Philip Withnall [Fri, 14 Mar 2014 09:24:08 +0000 (09:24 +0000)]
agent: Factor out a tiny bit of common code
Philip Withnall [Fri, 14 Mar 2014 09:20:53 +0000 (09:20 +0000)]
agent: Limit printed length of uname and password in debug output
At this point in the code, neither the username nor password are
nul-terminated, so printing them in the debug output as nul-terminated
strings can easily result in rubbish being printed after them.
Fix this by specifying the string length in the printf() format string.
Finally my terminal will no longer ask me to install N’Ko fonts when
running the libnice tests.
Philip Withnall [Tue, 15 Apr 2014 17:06:44 +0000 (18:06 +0100)]
agent: Fix a leak in nice_output_stream_write() with a NULL cancellable
If @cancellable is NULL in a call to nice_output_stream_write(), the
WriteData struct is created with a reference count of 4, but only two
operations are scheduled which will result in its reference count being
decremented. The third operation is only scheduled if @cancellable is
non-NULL (and the final reference is dropped unconditionally at the end
of the function).
Fix this by properly implementing reference counting for WriteData,
rather than hard-coding the expected number of references in a fragile
and unmaintainable way.
Olivier Crête [Wed, 2 Apr 2014 15:25:27 +0000 (11:25 -0400)]
tcp-bsd: Don't clear error that hasn't been set
Olivier Crête [Wed, 9 Apr 2014 03:10:34 +0000 (23:10 -0400)]
agent: Don't return the socket to the app in any reliable case
Youness Alaoui [Tue, 8 Apr 2014 01:30:49 +0000 (21:30 -0400)]
No need to strdup foundation in new_selected_pair since we queue signal
Olivier Crête [Wed, 9 Apr 2014 02:43:30 +0000 (22:43 -0400)]
pseudotcp: Also cause Writable callback to be emitted if can_send() says no
The GOutputStream based systems can sometimes call this, decide the stream is
not writable and then poll for it. We have to make sure that poll is woken up.
Youness Alaoui [Fri, 4 Apr 2014 06:43:20 +0000 (02:43 -0400)]
Fix TCP TURN for Google compatibility. Message length was sent uninitialized
Youness Alaoui [Tue, 1 Apr 2014 00:36:58 +0000 (20:36 -0400)]
Small cleaning of tcp-bsd.c
Jakub Adam [Sat, 4 Jun 2011 21:25:33 +0000 (23:25 +0200)]
Fix possible segfault in stun_message_validate_buffer_length()
Philip Withnall [Thu, 3 Apr 2014 11:29:04 +0000 (12:29 +0100)]
build: Check for [s]size_t before redefining them on MinGW
MinGW defines size_t and ssize_t for us, so we should not
unconditionally redefine them in stun/win32_common.h. Add an
AC_CHECK_TYPES configure check to avoid this.
Philip Withnall [Thu, 3 Apr 2014 11:22:27 +0000 (12:22 +0100)]
agent: Define IN6_ARE_ADDR_EQUAL macro when building under MinGW
Older versions of MinGW don’t define IN6_ARE_ADDR_EQUAL, as normally
defined in netinet/in.h. Conditionally define it in address.c to fix the
build on MinGW.
MinGW has added support for the macro here:
https://github.com/mirror/mingw-w64/commit/
0f4899473c4ba2e34fa447b1931a04e38c1f105e
Based on a patch originally by Luciana Fujii Pontello
<luciana@fujii.eti.br>.
Olivier Crête [Wed, 2 Apr 2014 01:41:04 +0000 (21:41 -0400)]
pseudotcp: Validate option lengths
Olivier Crête [Tue, 1 Apr 2014 15:00:55 +0000 (11:00 -0400)]
Remove all traces of compile time marshallers
Olivier Crête [Mon, 31 Mar 2014 23:28:24 +0000 (19:28 -0400)]
agent: Use generic marshaller
Olivier Crête [Mon, 31 Mar 2014 23:17:28 +0000 (19:17 -0400)]
Initialize variables to reduce unexpected behavior in case something goes wrong
Olivier Crête [Mon, 31 Mar 2014 23:15:07 +0000 (19:15 -0400)]
Rename variables that shadow global definitions
Olivier Crête [Mon, 31 Mar 2014 22:32:40 +0000 (18:32 -0400)]
stun: Use struct sockaddr_storage * for any pointer that we write to
Some platforms have a larger alignment requirement for struct sockaddr_* than
for plain struct sockaddr, in that case, we need to make sure that the incoming pointer
has the right alignement before taking it in.
Olivier Crête [Mon, 31 Mar 2014 21:46:34 +0000 (17:46 -0400)]
stun tests: Fix a bunch of issues found by more aggressive GCC warnings
Olivier Crête [Mon, 31 Mar 2014 21:46:15 +0000 (17:46 -0400)]
Don't mix gsize vs size_t, seems like they're not always the same size
Olivier Crête [Mon, 31 Mar 2014 21:45:36 +0000 (17:45 -0400)]
candidate: Use explicit 64-bit constants to make 32-bit gcc happy
Olivier Crête [Mon, 31 Mar 2014 21:44:45 +0000 (17:44 -0400)]
pseudotcp: Don't mix "long" and guint, one is signed, the other is unsigned
So use guint64 everywhere, this is never supposed to be negative.
Olivier Crête [Sun, 30 Mar 2014 01:28:02 +0000 (21:28 -0400)]
tcp-turn: Don't access output message after freeing it
Olivier Crête [Sun, 30 Mar 2014 01:23:40 +0000 (21:23 -0400)]
turn: Don't overwrite source, destroy it first
Olivier Crête [Sun, 30 Mar 2014 01:23:11 +0000 (21:23 -0400)]
turn: Don't access list node after freeing it
Olivier Crête [Fri, 28 Mar 2014 21:38:01 +0000 (17:38 -0400)]
component: Set dummy callback from cancellable GSource
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.
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.
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.
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
Olivier Crête [Fri, 28 Mar 2014 00:13:55 +0000 (20:13 -0400)]
turn: Put timeouts on the specific main context
Olivier Crête [Thu, 27 Mar 2014 21:55:31 +0000 (17:55 -0400)]
turn: Don't try to process empty messages
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.
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
Olivier Crête [Thu, 27 Mar 2014 21:51:03 +0000 (17:51 -0400)]
pseudotcp: Also accept NiceInputMessage array with a single message
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
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
Olivier Crête [Thu, 27 Mar 2014 21:49:43 +0000 (17:49 -0400)]
test-fullmode: Only wait for data on component 1
Olivier Crête [Thu, 27 Mar 2014 16:33:23 +0000 (12:33 -0400)]
tcp-bsd: Use default main context if none specified
Olivier Crête [Thu, 27 Mar 2014 07:54:32 +0000 (03:54 -0400)]
turn-tcp: Don't corrupt messages
Olivier Crête [Sat, 15 Mar 2014 03:53:06 +0000 (23:53 -0400)]
agent: Free every parameter
Fixes off-by-one error
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
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.
Olivier Crête [Fri, 7 Mar 2014 02:38:07 +0000 (21:38 -0500)]
NEWS: Remove superfluous empty lines
Olivier Crête [Fri, 7 Mar 2014 02:30:26 +0000 (21:30 -0500)]
Version 0.1.5.1
Olivier Crête [Fri, 7 Mar 2014 02:21:37 +0000 (21:21 -0500)]
Version 0.1.5
Olivier Crête [Fri, 7 Mar 2014 01:51:23 +0000 (20:51 -0500)]
configure: Remove -Wunsafe-loop-optimizations, it causes false warnings
Olivier Crête [Fri, 7 Mar 2014 01:45:43 +0000 (20:45 -0500)]
tests: Add private header to tarball
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
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
Olivier Crête [Thu, 6 Mar 2014 22:06:16 +0000 (17:06 -0500)]
doc: Update doc generation
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
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.
Philip Withnall [Wed, 5 Mar 2014 10:45:00 +0000 (10:45 +0000)]
agent: Ensure the pending signal queue is cleared on dispose
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.
Olivier Crête [Tue, 25 Feb 2014 05:48:56 +0000 (00:48 -0500)]
tests: Use dynamically allocated port for 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
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
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
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
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.
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.
Olivier Crête [Mon, 24 Feb 2014 23:59:39 +0000 (18:59 -0500)]
Ignore .trs and .log file from newer automake
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.
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
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.
Olivier Crête [Mon, 24 Feb 2014 22:25:50 +0000 (17:25 -0500)]
iostream: remove re-entrant call into NiceAgent
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
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().
Philip Withnall [Fri, 31 Jan 2014 11:52:15 +0000 (11:52 +0000)]
agent: Fix inlining of nice_debug() if NDEBUG is defined
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.
Philip Withnall [Fri, 31 Jan 2014 11:43:03 +0000 (11:43 +0000)]
agent: Improve debug output
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.
Olivier Crête [Fri, 21 Feb 2014 20:05:59 +0000 (15:05 -0500)]
docs: Remove NiceIOStream, nothing specific to document
Olivier Crête [Fri, 21 Feb 2014 19:34:28 +0000 (14:34 -0500)]
agent: returning 0 valid messages is valid, it means EOF
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
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
Olivier Crête [Wed, 19 Feb 2014 04:52:37 +0000 (23:52 -0500)]
outputstream: Trigger the pollable source on error or removal
Olivier Crête [Thu, 13 Feb 2014 20:14:23 +0000 (15:14 -0500)]
agent: Fix compiler warnings
Olivier Crête [Wed, 5 Feb 2014 23:16:02 +0000 (18:16 -0500)]
configure: Add newline ignoring
Otherwise it ran the "yes" command
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
Olivier Crête [Fri, 31 Jan 2014 06:25:57 +0000 (01:25 -0500)]
pseudotcp: Remove one duplicated call to g_get_monotonic_time()
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
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.
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
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
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
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.
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
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
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
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
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
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.
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.
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.
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.
Philip Withnall [Thu, 16 Jan 2014 16:11:25 +0000 (16:11 +0000)]
tests: Update test-send-recv to support vectored I/O