public void updateRecord(long now, DNSRecord rec)
    {
        // We do not want to block the entire DNS while we are updating the
        // record for each listener (service info)
        List listenerList = null;
        synchronized (this)
        {
            listenerList = new ArrayList(listeners);
        }
        for (final Iterator iterator = listenerList.iterator(); iterator.hasNext();)
        {
            final DNSListener listener = (DNSListener) iterator.next();
            listener.updateRecord(this, now, rec);
        }
        if (rec.type == DNSConstants.TYPE_PTR || rec.type == DNSConstants.TYPE_SRV)
        {
            List serviceListenerList = null;
            synchronized (serviceListeners)
            {
                serviceListenerList = (List) serviceListeners.get(rec.name.toLowerCase());
                // Iterate on a copy in case listeners will modify it
                if (serviceListenerList != null)
                {
                    serviceListenerList = new ArrayList(serviceListenerList);
                }
            }
            if (serviceListenerList != null)
            {
                final boolean expired = rec.isExpired(now);
                final String type = rec.getName();
                final String name = ((DNSRecord.Pointer) rec).getAlias();
                // DNSRecord old = (DNSRecord)services.get(name.toLowerCase());
                if (!expired)
                {
                    // new record
                    final ServiceEvent event = new ServiceEventImpl(this, type, toUnqualifiedName(
                            type, name), null);
                    for (final Iterator iterator = serviceListenerList.iterator(); iterator
                            .hasNext();)
                    {
                        ((ServiceListener) iterator.next()).serviceAdded(event);
                    }
                }
                else
                {
                    // expire record
                    final ServiceEvent event = new ServiceEventImpl(this, type, toUnqualifiedName(
                            type, name), null);
                    for (final Iterator iterator = serviceListenerList.iterator(); iterator
                            .hasNext();)
                    {
                        ((ServiceListener) iterator.next()).serviceRemoved(event);
                    }
                }
            }
        }
    }