- 31 Jan, 2014 40 commits
-
-
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.
-
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()
-
Olivier Crête authored
-
Olivier Crête authored
Otherwise it produces a deadlock
-
Olivier Crête authored
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.
-
Olivier Crête authored
-
Olivier Crête authored
-
Olivier Crête authored
-
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.
-
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.
-
Philip Withnall authored
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().
-
Philip Withnall authored
-
Philip Withnall authored
-
Philip Withnall authored
Sharing is caring.
-
Philip Withnall authored
-
Philip Withnall authored
This prevents the pseudotcp socket from being destroyed from within a callback.
-
Philip Withnall authored
When closing a socket, ensure its private data structure is set to NULL. When sending a message fails to construct a new socket address, ensure the pointer to the old address (which has just been unreffed) is removed. This makes debugging problems with sockets being freed early much easier.
-
Philip Withnall authored
-
Philip Withnall authored
Previously, the pseudo-TCP implementation’s readable() callback would only be invoked when new data was received if it was enabled. The callback is enabled by reading all data from the TCP input buffer until EWOULDBLOCK is returned. Reading all that data is not possible if the client buffer is of a limited size, and can lead to livelocks if the client reads exactly the number of bytes in the TCP input buffer (i.e. its buffer size matches the TCP buffer fill level). Instead, always invoke the readable() callback. This might be slightly less performant, but the whole pseudo-TCP implementation is a shambles anyway, and the callbacks need removing, so why not?
-
Philip Withnall authored
-
Philip Withnall authored
-
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.
-
Philip Withnall authored
This allows creation of a NiceIOStream from an existing NiceAgent instance.
-
Philip Withnall authored
This adds three new classes: • NiceIOStream • NiceInputStream • NiceOutputStream which allow wrapping a single stream/component pair in an I/O stream which can be used with the standard GIO functions. The streams are constructed as wrappers around a NiceAgent, with changes to the NiceAgent’s properties affecting all instantiated streams. Streams are only supported for reliable connections. If the NiceAgent stream which underlies a NiceInputStream, NiceOutputStream or NiceIOStream is removed, the I/O stream is marked as closed. This is based on work originally done by Youness Alaoui <youness.alaoui@collabora.co.uk>.
-
Philip Withnall authored
This is a type of GSource which proxies all poll events from the sockets in a Component. It’s necessary for the implementation of GPollableInputStream and GPollableOutputStream. This adds no new external API, but does add ComponentSource and component_source_new() as new internal API.
-
Philip Withnall authored
This adds GError and GCancellable parameters to the existing nice_agent_send() API, and is identical in all other respects (notably, it is non-blocking). The GCancellable is currently unused, but could be used in future if the API grows to support blocking writes. The GError is used to return more interesting error codes than just ‘-1’.
-
Philip Withnall authored
This is a blocking receive function, designed to be called from a worker thread. It cannot be used in conjunction with the existing nice_agent_attach_recv() API, as the blocking receive and the GSource would compete over access to the single copy of the data in the kernel’s receive buffer.
-
Philip Withnall authored
Rather than handle GSource creation, attachment and removal in NiceAgent, handle it inside Component. This brings it closer to the networking code, and improves encapsulation of the state of each Component.
-
Philip Withnall authored
Mostly problems with the specifier for gsize.
-
Philip Withnall authored
If the Component’s I/O receiver machinery is invoked from a thread which can’t acquire the main context specified for the I/O callbacks, the callbacks need to be queued as idle handlers in that main context. This is needed for the case where blocking reads are being performed in one thread, with their callbacks needing to be delivered in another thread. This introduces a new fine-grained lock to Component: io_mutex. This protects accesses to Component->io_callback, Component->io_user_data and Component->pending_io_callbacks. If being locked at the same time as the main agent lock, it must always be locked afterwards, but the agent lock does not *have* to be held in order to lock io_mutex.
-
Philip Withnall authored
-
Philip Withnall authored
It was allocated separately and always set, which is a wasted allocation. Instead, pull the NiceAgent and Stream pointers into the Component directly, and eliminate the redundant allocation. This also means the NiceAgent and Stream are available for use elsewhere in the Component code (not just with TCP stuff).
-
Philip Withnall authored
Add ‘_locked’ to the name to clarify that it must be called with the agent’s lock already held.
-
Philip Withnall authored
…rather than gchar*. This differentiates binary buffers from strings a little better, although the two types are functionally equivalent. Also use gsize for buffer sizes, rather than guint.
-
Philip Withnall authored
Compartmentalise the handling of setting and clearing the user-provided per-Component I/O callbacks. Data flows from the socket, through nice_agent_g_source_cb(), to component_emit_io_callback() which calls the callback provided by the user when originally attaching to the stream/component.
-
Philip Withnall authored
This compartmentalises it a little more, reducing the spread of state-changing code from three files down to one. The key change is the switch from using two GSLists of NiceSockets and GSources in Component, to using a single GSList of a struct { NiceSocket, GSource }. This is possible because there is at most one GSource per NiceSocket. This change reduces memory overhead (from the GSList structures) slightly, and makes the relationship between sockets and sources much clearer.
-
Philip Withnall authored
Move all functionality which is unrelated to the GSource into _nice_agent_recv().
-
Philip Withnall authored
This is emitted when one or more streams are removed from the agent due to a call to nice_agent_remove_stream().
-
Philip Withnall authored
A g_usleep() was introduced in commit e22ecb19 to fix a potential race where the non-main threads would finish all their work before the error_loop was started, leaving the error_loop to run for 30s then abort the test. A better fix, instead of doing a racy sleep, is to have the non-main threads spin until the error_loop is running. GLib takes care of all the locking for us, and since we don’t care about efficiency for test cases, spinning is fine (the wait is also going to be quite short).
-
Philip Withnall authored
Add various compiler warnings to the different levels of --enable-compile-warnings. No particular scheme has been used to assign different warnings to different levels, other than that more critical ones are typically enabled at lower levels upwards. All code in libnice except the tests currently compiles with --enable-compile-warnings=error.
-