[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MIT-Scheme-devel] Re: DNS queries, blocking C calls, and non-file-descr
Taylor R Campbell
[MIT-Scheme-devel] Re: DNS queries, blocking C calls, and non-file-descriptor events
Sun, 13 Aug 2006 16:35:55 +0000
IMAIL/1.21; Edwin/3.116; MIT-Scheme/7.7.90.+
After considering this further, I decided to rewrite the library with
a slightly different approach -- indeed, the approach I had used
originally and then discarded --, which is considerably less general
but more scalable for this particular application of a Scheme wrapper
around a library call.
Now there is a single pthread for running getaddrinfo(3) and a single
pipe to which it writes a byte on the completion of a call to
getaddrinfo(3). It's not so useful as a general-purpose thread-safe
wrapper around getaddrinfo(3) to be called from arbitrary pthreads,
but since the single Scheme pthread will be the only client, this is
all that we need, and this involves only a single pipe (plus one
Scheme-level thread to manage the foreign calls and responses in the
The new code -- still crude and unpolished, but working (for me) -- is
temporarily at <http://mumble.net/~campbell/tmp/s48-addrinfo.tar.gz>.
If you want to run this code, just read the README for instructions.
The library will give you raw C sockaddrs; you can use s48-grovel,
from <http://mumble.net/~campbell/darcs/s48-grovel/>, or s48-network,
from <http://mumble.net/~campbell/darcs/s48-network/>, to work with
the raw C sockaddr structs in the addrinfo results, which my code
makes no effort to translate to Scheme data.
(Some time soon I might also translate this to Matt Birkholz's FFI for