[Nice] patch for g_io_create_watch glib bug

Youness Alaoui youness.alaoui at collabora.co.uk
Thu Feb 23 17:32:36 PST 2012


That's an interesting bug. I didn't know about this limitation of glib.
Refactoring libnice in order to have a single watch would be impractical because
of the way it's done.
While I'm inclined to accept this patch as a temporary workaround, I've
discussed it with a colleague who said it shouldn't be merged, but instead a
patch to glib should be made. I will agree with him on this one, as I think that
adding workaround over workaround will add complexity to the code in the long
term, and since this is quite an ugly hack (I admit not having any other
solution for it), it is best to leave it out.
My suggestion to you then would be to fix it directly in glib and submit a patch
to the glib team instead.
This bug has been present and known since 2006, but no proper patch has been
submitted for it yet, so if you could fix it once and for all, many people would
benefit from that.
Here's the related bug : https://bugzilla.gnome.org/show_bug.cgi?id=338943

On another note, we are starting to get a lot of #ifdefs for windows, and it's
making the code less maintainable, my colleague, Olivier Crete, suggested using
GSocket. I didn't know that existed, but I think it would be greatly beneficial
to port libnice to using GSocket instead of normal sockets with lots of #ifdefs.
If you are up for it, it would be great if you could send a patch that does
that. There might even be a fix for this g_io_create_watch inside g_socket. I
can see that it doesn't use g_io_create_watch, but uses something else based on
pollfd and a concatenation of all requested conditions, so it's possible that it
fixes it.
See http://developer.gnome.org/gio/2.30/GSocket.html and especially

Let me know what you think.


On 02/23/2012 12:14 PM, Madaro Livio wrote:
> Hi,
> Here is the second one for review.
> The glib function g_io_create_watch has a bug on Windows: multiple call to g_io_create_watch on the same socket won't work (https://bugzilla.gnome.org/show_bug.cgi?id=338943 )
> Libnice calls  g_io_create_watch two times: the first one to set the callback for the socket condition G_IO_IN, the second one for the socket condition G_IO_OUT when the socket send returns WSAEWOULDBLOCK and data is queued for retransmission. The problem is that calling g_io_create_watch the second time "delete" the previous one and the callback for G_IO_IN will never be called.
> The patch is a workaround that uses a polling timer to avoid the second g_io_create_watch call.
> I know polling is not a very good solution, but it is simple (I modified just few lines of code) otherwise libnice should be modified to call g_io_create_watch just one time.
> Regards,
> Livio
> Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie.
> This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks.
> _______________________________________________
> nice mailing list
> nice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nice

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20120223/35ce7d74/attachment.pgp>

More information about the nice mailing list