gio/tests: Prevent hangs and aborts in socket-listener
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 30 Nov 2014 22:17:51 +0000 (22:17 +0000)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 7 Dec 2014 06:40:18 +0000 (08:40 +0200)
commit7d9816934e6a233369a2df1282a49d1549d9fa0f
tree1f85e4a6f5f6ed994ebd4f5666257f526aac8002
parent53abf0dc7d22d8a150fdc6162ef212cb5aa87c2f
gio/tests: Prevent hangs and aborts in socket-listener

Fix two problems:
1) If g_socket_service_stop is called before the accept call is requeued,
then the reference count won't decrease and this code will hang forever:
  while (G_OBJECT (service)->ref_count == ref_count)
    g_main_context_iteration (NULL, TRUE);

2) Sometimes the testcase fails (maybe 1 in 200 times for me):
GLib-GIO:ERROR:socket-listener.c:73:connection_cb: assertion failed
(G_OBJECT (service)->ref_count == 2): (3 == 2)
Aborted (core dumped)

The problem is that depending on ordering, cancellation of the async
listener can require further main context iterations before it releases
the reference on the socket service. Furthermore, in some cases, it
requires at least one iteration.

https://bugzilla.gnome.org/show_bug.cgi?id=712570
gio/tests/socket-listener.c