Changeset 105

Show
Ignore:
Timestamp:
03/02/07 12:14:20 (1 year ago)
Author:
tulloss2
Message:

Fixed annoying crash where delegate was being referred to in native code after it had already been disposed of in managed code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/Mono.Zeroconf/RegisterService.cs

    r26 r105  
    4545    public sealed class RegisterService : Service, IDisposable 
    4646    { 
     47                private Native.DNSServiceRegisterReply regReply; 
    4748        private Thread thread; 
    4849        private ServiceRef sd_ref; 
     
    5758        public RegisterService(string name, string replyDomain, string regtype) : base(name, replyDomain, regtype) 
    5859        { 
     60                        regReply = OnRegisterReply; 
    5961        } 
    6062         
     
    105107                Marshal.Copy(TxtRecord.RawBytes, txt_rec, 0, txt_rec_length); 
    106108            } 
    107              
     109 
    108110            ServiceError error = Native.DNSServiceRegister(out sd_ref,  
    109111                auto_rename ? ServiceFlags.None : ServiceFlags.NoAutoRename, InterfaceIndex, 
    110112                Name, RegType, ReplyDomain, HostTarget, (ushort)port, txt_rec_length, txt_rec, 
    111                 OnRegisterReply, IntPtr.Zero); 
     113                regReply, IntPtr.Zero); 
    112114 
    113115            if(error != ServiceError.NoError) { 
     
    120122        public void Dispose() 
    121123        { 
     124                        GC.KeepAlive(regReply); 
     125 
    122126            if(thread != null) { 
    123127                thread.Abort(); 
  • dmp/trunk/Mono.Zeroconf/ServiceBrowser.cs

    r26 r105  
    108108        private void ProcessStart() 
    109109        { 
     110                        Native.DNSServiceBrowseReply browseReply = OnBrowseReply; 
     111                        GC.KeepAlive(browseReply); 
    110112            ServiceError error = Native.DNSServiceBrowse(out sd_ref, ServiceFlags.Default, 
    111                 interface_index, regtype,  domain, OnBrowseReply, IntPtr.Zero); 
     113                interface_index, regtype,  domain, browseReply, IntPtr.Zero); 
    112114 
    113115            if(error != ServiceError.NoError) {