Skip to content

gsocketlistener: Fix multiple returns of GTask when accepting sockets

When calling g_socket_listener_accept_socket_async() on a GSocketListener with multiple sockets, the accept_ready() callback is called for the first incoming connection on each socket. It will return success/failure for the entire accept_socket_async() GTask, and then free the GSources for listening for incoming connections on the other sockets in the GSocketListener. The GSources are freed when the GTask is finalised.

However, if incoming connections arrive for multiple sockets within the same GMainContext iteration, accept_ready() will be called multiple times, and will call g_task_return_() multiple times, before the GTask is finalised. Calling g_task_return_() multiple times is not allowed.

Propagate the first success/failure, as before, but then ignore all subsequent incoming connections until the GTask is finalised.

Signed-off-by: Philip Withnall withnall@endlessm.com

Merge request reports