mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
fix for bnug #38981
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36621 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3ea153f91b
commit
a446155e68
2 changed files with 32 additions and 21 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-05-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSMessagePortNameServer.m: fix for bug #38981
|
||||
|
||||
2013-05-13 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/Foundation/NSKeyedArchiver.h,
|
||||
|
|
|
@ -131,7 +131,7 @@ static void clean_up_names(void)
|
|||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
NSFileManager *mgr;
|
||||
NSString *path;
|
||||
NSString *pref;
|
||||
NSString *pid;
|
||||
NSString *file;
|
||||
NSEnumerator *files;
|
||||
|
||||
|
@ -149,34 +149,41 @@ static void clean_up_names(void)
|
|||
path = NSTemporaryDirectory();
|
||||
path = [path stringByAppendingPathComponent: @"NSMessagePort"];
|
||||
path = [path stringByAppendingPathComponent: @"names"];
|
||||
pref = [NSString stringWithFormat: @"%i.",
|
||||
pid = [NSString stringWithFormat: @"%i",
|
||||
[[NSProcessInfo processInfo] processIdentifier]];
|
||||
mgr = [NSFileManager defaultManager];
|
||||
files = [[mgr directoryContentsAtPath: path] objectEnumerator];
|
||||
while ((file = [files nextObject]) != nil)
|
||||
{
|
||||
NSString *old = [path stringByAppendingPathComponent: file];
|
||||
NSString *port = [NSString stringWithContentsOfFile: old];
|
||||
NSArray *lines;
|
||||
|
||||
if (YES == [port hasPrefix: pref])
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old);
|
||||
[mgr removeFileAtPath: old handler: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
int pid = [port intValue];
|
||||
lines = [[NSString stringWithContentsOfFile: old]
|
||||
componentsSeparatedByString: @"\n"];
|
||||
if ([lines count] == 2)
|
||||
{
|
||||
NSString *opid = [lines objectAtIndex: 1];
|
||||
|
||||
if (pid > 0)
|
||||
{
|
||||
if (NO == [NSProcessInfo _exists: pid])
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort",
|
||||
@"Removing old name %@ for process %d", old, pid);
|
||||
[mgr removeFileAtPath: old handler: nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (YES == [opid isEqual: pid])
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old);
|
||||
[mgr removeFileAtPath: old handler: nil];
|
||||
}
|
||||
else if ([opid intValue] > 0)
|
||||
{
|
||||
if (NO == [NSProcessInfo _exists: [opid intValue]])
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort",
|
||||
@"Removing old name %@ for process %@", old, pid);
|
||||
[mgr removeFileAtPath: old handler: nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort", @"Removing bad name %@", old);
|
||||
[mgr removeFileAtPath: old handler: nil];
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue