mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 02:01:03 +00:00
Avahi bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31492 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
092e9227b5
commit
bdaf339b92
2 changed files with 26 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2010-10-08 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Source/GSAvahiRunLoopIntegration.m: Fix some bugs:
|
||||||
|
- Remove an extra retain of the NSTimer which was leaking memory.
|
||||||
|
- When passed a NULL struct timeval * from avahi, invalidate
|
||||||
|
the timer and don't schedule a new one.
|
||||||
|
|
||||||
2010-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSPredicate.m: Add simple implementation of
|
* Source/NSPredicate.m: Add simple implementation of
|
||||||
|
|
|
@ -222,27 +222,34 @@
|
||||||
timer = nil;
|
timer = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = [[NSTimer timerWithTimeInterval: interval
|
// NOTE: the timer ivar is a weak reference; runloops retain their
|
||||||
|
// timers.
|
||||||
|
timer = [NSTimer timerWithTimeInterval: interval
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(didTimeout:)
|
selector: @selector(didTimeout:)
|
||||||
userInfo: nil
|
userInfo: nil
|
||||||
repeats: NO] retain];
|
repeats: NO];
|
||||||
[[ctx runLoop] addTimer: timer
|
[[ctx runLoop] addTimer: timer
|
||||||
forMode: [ctx mode]];
|
forMode: [ctx mode]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTimerToTimeval: (const struct timeval*)tv
|
- (void)setTimerToTimeval: (const struct timeval*)tv
|
||||||
{
|
{
|
||||||
// Construct a NSTimeInterval for the timer:
|
// Invalidate the old timer
|
||||||
NSTimeInterval interval = 0;
|
if (timer != nil)
|
||||||
|
{
|
||||||
|
[timer invalidate];
|
||||||
|
timer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
if (NULL != tv)
|
if (NULL != tv)
|
||||||
{
|
{
|
||||||
interval = (NSTimeInterval)tv->tv_sec;
|
// Construct a NSTimeInterval for the timer:
|
||||||
|
NSTimeInterval interval = (NSTimeInterval)tv->tv_sec;
|
||||||
interval += (NSTimeInterval)(tv->tv_usec / 1000000.0);
|
interval += (NSTimeInterval)(tv->tv_usec / 1000000.0);
|
||||||
}
|
|
||||||
[self setTimerToInterval: interval];
|
[self setTimerToInterval: interval];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
- (id)initWithCallback: (AvahiTimeoutCallback)aCallback
|
- (id)initWithCallback: (AvahiTimeoutCallback)aCallback
|
||||||
andContext: (GSAvahiRunLoopContext*)aCtx
|
andContext: (GSAvahiRunLoopContext*)aCtx
|
||||||
forTimeval: (const struct timeval*)tv
|
forTimeval: (const struct timeval*)tv
|
||||||
|
@ -264,8 +271,8 @@
|
||||||
{
|
{
|
||||||
if ([timer isValid])
|
if ([timer isValid])
|
||||||
{
|
{
|
||||||
[timer invalidate];
|
|
||||||
fireDate = [[timer fireDate] retain];
|
fireDate = [[timer fireDate] retain];
|
||||||
|
[timer invalidate];
|
||||||
timer = nil;
|
timer = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue