[Gambas-devel] DnsClient patch

Daniel Campos daniel.campos at ...103...
Thu Feb 17 09:45:09 CET 2005


>
> I guess there's no way to get around not using #ifdefs in network code :(
>
> Cygwin's gethostbyname and getaddrbyname appears to be safe between 
> threads if you put it in a mutex lock while running the function and 
> copying data out of the returned struct.
>
> Is the point of Async vs Sync just whether to block or not? Or is it 
> supposed to be able to run multiple resolves at once?
>
> I don't see any way to do the latter cleanly on Windows right now. :(


Well, at least with that implementation we are more POSIX compatible and 
the conditional compilation for
Solaris seems to be removed.
Async allows to not block and due to this, it allows to run multiple 
resolves at once...

>
> BTW, on line 178, does that make a thread block if another thread got 
> to the semaphore first? I don't know too much about multithreaded
> programming yet... Still a little confused about locking...
>
I have a pipe in order to cummunicate the main thread with the rest of 
threads. This is a common resource in which
only a thread can write at once, so I use semaphores to control the 
order in which various threads write in the pipe,
and the order in which the main thread reads from the pipe. You have 
more details at {gambas sources}/src/lib/net/doc/threading.swx .

If gethostbyname() and gethostbyaddr() are really thread safe with 
Cygwin, you can just patch the dns_get_ip and
dns_get_name functions, following exactly the same structure but 
extracting data from these two functions, so
you do not have to care very much about threading...

Regards,

D. Campos




More information about the Devel mailing list