[Gajim-devel] blocking getaddrinfo
Tomas Karasek
tom.to.the.k at gmail.com
Thu Jun 26 23:20:05 CEST 2008
Hi,
I'm trying to get rid of the GUI-blocking timeout that occurs on
getaddrinfo() during connecting to XMPP server when network is down.
In such case, getaddrinfo blocks for quite a long time and roster window
doesn't respond. It happens on connect after executing Gajim, and also
when Gajim disconnects due to a network failiure and then tries to
reconnect (and network is still down).
I was talking about that with Asterix and because we didn't find any
AAAA-capable asynchronous python dns library, we came up with following:
Because SRV requests are done asynchronously via nslookup in pipe polled
in IdleQueue (src/common/nslookup.py), it's possible to detect that DNS
server is not available from result of asynchronous SRV request. And -
if we know that DNS SRV request failed, then don't do the getaddrinfo call.
But now I found out that there is a short blocking timeout when closing
pipe with running nslookup - on self.pipe.close(), so this is not a
solution for GUI blocking on connect.
I already tried putting getaddrinfo to separate thread, but it just
didn't work for me - the thread was waiting even after a successful gai
call... As for dns libraries - adns can't do AAAA requests, pydns and
dnspython can't operate asynchronously.
What I'm looking for is either
- some elegant way how to do both A and AAAA requests asynchronously
(like nonblocking getaddrinfo) which would be a nice solution
or
- nonblocking detect that network is down which would allow to avoid
needless call of getaddrinfo (temporary solution until some
suitable library appears)
Do you have any ideas/suggestions on this?
rgds,
tomk
--
Tomas Karasek
jabber: tom.to.the.k at jabber.cz
GSoC blog: http://tomk-soc08.blogspot.com/
More information about the Gajim-devel
mailing list