Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Damien Thébault
On Tue, Jul 1, 2008 at 20:03, Jonathan Schleifer <[EMAIL PROTECTED]> wrote:
> "Damien Thébault" <[EMAIL PROTECTED]> wrote:
>> Ok, let's put this code somewhere now :)
>> I'll maybe post the patch for gajim if someone is interested.
>
> Feel free to post it here so it can be applied post-0.12.

The project is now hosted here: https://code.launchpad.net/libasyncns-python

Attached is the patch I talked about before.
It:
 - creates src/common/asyncresolver.py
 - removes src/common/nslookup.py (not really needed, but I wanted to
be sure it wasn't used anymore, feel free to keep it ;))
 - adds resolver.process() in process_connections() (which is only
called once every 2s on unix, by the way)

You need to install the python binding libasyncns.so, you don't have
to install it on the system, put the file next to asyncresolver.py and
it will work!

As the name suggests, it applies agains gajim 0.11.4.
I don't think it should be applied as-is, maybe a complete resolving
framework should be set-up (to be sure that every hostname is resolved
using it).

In addition, any comment is welcome concerning libasyncns-python.

Regards,
-- 
Damien Thebault


gajim-0.11.4-libasyncns.patch
Description: Binary data
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel

Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Jonathan Schleifer
"Damien Thébault" <[EMAIL PROTECTED]> wrote:

> Ok, let's put this code somewhere now :)
> I'll maybe post the patch for gajim if someone is interested.

Feel free to post it here so it can be applied post-0.12.

-- 
Jonathan


signature.asc
Description: PGP signature
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel

Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Damien Thébault
On Tue, Jul 1, 2008 at 16:40, Jonathan Schleifer <[EMAIL PROTECTED]> wrote:
> "Damien Thébault" <[EMAIL PROTECTED]> wrote:
>
> GTalk uses SRV records. Maybe you don't check them yet?
> For  records, my server (webkeks.org) provides them - so if you
> need a server to test.
>

It was the other way around: non-SRV records (I did specify the gtalk
server manually because one time it didn't work properly without that)
were blocking everything (if a wrong nameserver was provided in
/etc/resolv.conf), I did a small trick in connection.py to call my
resolver and to change the host in self._hosts once resolved.
This way, it never hangs.
For  records, I'm able to get them with getaddrinfo (IPv6
addresses are in the list).

Ok, let's put this code somewhere now :)
I'll maybe post the patch for gajim if someone is interested.
-- 
Damien Thebault
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel


Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Jonathan Schleifer
"Damien Thébault" <[EMAIL PROTECTED]> wrote:

> I even replaced the resolver in the gajim code by a small wrapper and
> it's working well.
> I'd like to test the case here, the only case where there is a problem
> for me is with a google talk account (doesn't seems to use the
> resolver, is this the issue?). I didn't try  resolution either,
> does anyone have a usecase?

GTalk uses SRV records. Maybe you don't check them yet?
For  records, my server (webkeks.org) provides them - so if you
need a server to test.

-- 
Jonathan


signature.asc
Description: PGP signature
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel

Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Damien Thébault
On Tue, Jul 1, 2008 at 15:39, Yann Leboulanger <[EMAIL PROTECTED]> wrote:
> Wow cool ! We unfortunatly don't have much time now because we'd like to
> release very very soon, but that would be very cool to finalize that. What
> are you plans about those bindings? Do you think to send them to author so
> that he can release them? Do you think to start  new project to them?
>
> But for sure it's interesting as it's the only async python module that
> allows  resolution.

I worked on it since my last mail, and I now have a clean module which
doesn't use swig. It's a pure C/python module, with correct classes.
The only missing part is error/exception handling, but it's fully
usable.

I even replaced the resolver in the gajim code by a small wrapper and
it's working well.
I'd like to test the case here, the only case where there is a problem
for me is with a google talk account (doesn't seems to use the
resolver, is this the issue?). I didn't try  resolution either,
does anyone have a usecase?

I discovered a small bug in libasyncns and I sent a mail to Lennart
Poettering about it, but didn't get any reply.
So I was planning to release it on my own, it's always possible to
include it later in libasyncns if we want to.
Other python bindings have a separate project (e.g. adns-python for
adsn), so it's not uncommon to do it this way.

I'll try to upload the binding today (I plan to host it on launchpad
since I'm mainly using bzr), even if it's not yet stable.

Regards.

(I'm posting from another mail address, because the webmail of my main
one is buggy as hell and break mailing-lists threading (and maybe
more))
-- 
Damien Thebault
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel


Re: [Gajim-devel] blocking getaddrinfo

2008-07-01 Thread Yann Leboulanger

Damien Thébault a écrit :

Le vendredi 27 juin 2008 à 11:45 +0200, Yann Leboulanger a écrit :

Tomas Karasek wrote:

What I'm looking for is either
 - some elegant way how to do both A and  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
suitablelibrary appears)

Do you have any ideas/suggestions on this?


Another solution is to create python bindings for libasyncns:
http://0pointer.de/lennart/projects/libasyncns/


Hello everyone,

After reading Tomas Karasek's mail, I found libasyncns too.

This afternoon, I hacked a python binding while I was on a train (and
some hours after that), and I'm now able to use libasyncns from python.

Currently, it's not very clean (currently it's a first draft), it's
using swig (so we can see some "garbage" from python, like wrappers, but
it has some interesting features too).

Anyway, I'm able to do the same things than the "asyncns-test.c" file
from the libasyncns' documentation [1] (but in ~25 lines instead of
~125) (see the file asyncns-test.py).

I'm joining the code with this mail, if someone is interested. For
example, it may be used to test how gajim may work with libasyncns
someday (but I don't know what gajim needs).
(I didn't put licensing information already but it's LGPL2+, like the
libasyncns library)

Keep in mind that this is a work in progress, currently:
 - exceptions should work
 - IPv6 isn't available in getnameinfo
 - I don't store values from requests so I can't use a query object
   twice
 - some functions are not implemented:
  asyncns_getnext(), asyncns_getnqueries(), asyncns_getuserdata(),
  asyncns_setuserdata(), asyncns_res_search(), asyncns_fd()...
 - this is not deeply tested, and for example I don't know how memory is
   managed

[1]: 
http://0pointer.de/lennart/projects/libasyncns/doxygen/asyncns-test_8c-example.html

Regards,


Wow cool ! We unfortunatly don't have much time now because we'd like to 
release very very soon, but that would be very cool to finalize that. 
What are you plans about those bindings? Do you think to send them to 
author so that he can release them? Do you think to start  new project 
to them?


But for sure it's interesting as it's the only async python module that 
allows  resolution.


--
Yann
___
Gajim-devel mailing list
Gajim-devel@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/gajim-devel