+/* $Id$ */
+
/***
This file is part of avahi.
private Protocol proto;
private string hostname;
private Protocol aproto;
+ private HostNameResolverCallback cb;
private IPAddress currentAddress;
private string currentHost;
this.proto = proto;
this.hostname = hostname;
this.aproto = aproto;
+ cb = OnHostNameResolverCallback;
}
~HostNameResolver ()
private void Start ()
{
- if (handle != IntPtr.Zero || (foundListeners.Count == 0 && timeoutListeners.Count == 0))
+ if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero ||
+ (foundListeners.Count == 0 && timeoutListeners.Count == 0))
return;
IntPtr hostPtr = Utility.StringToPtr (hostname);
- handle = avahi_host_name_resolver_new (client.Handle, iface, proto, hostPtr, aproto,
- OnHostNameResolverCallback, IntPtr.Zero);
+
+ lock (client) {
+ handle = avahi_host_name_resolver_new (client.Handle, iface, proto, hostPtr, aproto,
+ cb, IntPtr.Zero);
+ }
+
Utility.Free (hostPtr);
}
private void Stop (bool force)
{
- if (handle != IntPtr.Zero && (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) {
- avahi_host_name_resolver_free (handle);
- handle = IntPtr.Zero;
+ if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero &&
+ (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) {
+
+ lock (client) {
+ avahi_host_name_resolver_free (handle);
+ handle = IntPtr.Zero;
+ }
}
}