Author: mlytwyn
Date: Wed Mar  8 19:23:17 2017
New Revision: 40373

URL: http://svn.gna.org/viewcvs/gnustep?rev=40373&view=rev
Log:
Skip potential directories in private area on port name server initialize

Modified:
    libs/base/branches/gnustep_testplant_branch/Source/NSMessagePortNameServer.m

Modified: 
libs/base/branches/gnustep_testplant_branch/Source/NSMessagePortNameServer.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/NSMessagePortNameServer.m?rev=40373&r1=40372&r2=40373&view=diff
==============================================================================
--- 
libs/base/branches/gnustep_testplant_branch/Source/NSMessagePortNameServer.m    
    (original)
+++ 
libs/base/branches/gnustep_testplant_branch/Source/NSMessagePortNameServer.m    
    Wed Mar  8 19:23:17 2017
@@ -151,40 +151,43 @@
       path = NSTemporaryDirectory();
       path = [path stringByAppendingPathComponent: @"NSMessagePort"];
       path = [path stringByAppendingPathComponent: @"names"];
-      pid = [NSString stringWithFormat: @"%i",
-       [[NSProcessInfo processInfo] processIdentifier]];
+      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];
-          NSArray       *lines;
-          NSString      *line;
-          int           opid;
-
-         lines = [[NSString stringWithContentsOfFile: old]
-            componentsSeparatedByString: @"\n"];
-          if ([lines count] > 1
-            && (opid = [(line = [lines objectAtIndex: 1]) intValue]) > 0)
+        {
+          NSString     *old         = [path stringByAppendingPathComponent: 
file];
+          BOOL       isDirectory = NO;
+
+          // Skip potential directories from a previous run/reboot...
+          if ([mgr fileExistsAtPath: old isDirectory: &isDirectory] && 
(isDirectory == NO))
             {
-              if (YES == [line isEqual: pid])
+              NSArray       *lines;
+              NSString      *line;
+              int           opid;
+
+              lines = [[NSString stringWithContentsOfFile: old] 
componentsSeparatedByString: @"\n"];
+              if ([lines count] > 1 && (opid = [(line = [lines objectAtIndex: 
1]) intValue]) > 0)
                 {
-                  NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old);
-                  [mgr removeFileAtPath: old handler: nil];
+                  if (YES == [line isEqual: pid])
+                    {
+                      NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", 
old);
+                      [mgr removeFileAtPath: old handler: nil];
+                    }
+                  else if (NO == [NSProcessInfo _exists: opid])
+                    {
+                      NSDebugMLLog(@"NSMessagePort",
+                        @"Removing old name %@ for process %d", old, opid);
+                      [mgr removeFileAtPath: old handler: nil];
+                    }
                 }
-              else if (NO == [NSProcessInfo _exists: opid])
+              else
                 {
-                  NSDebugMLLog(@"NSMessagePort",
-                    @"Removing old name %@ for process %d", old, opid);
+                  NSDebugMLLog(@"NSMessagePort", @"Removing bad name %@", old);
                   [mgr removeFileAtPath: old handler: nil];
                 }
             }
-          else
-            {
-              NSDebugMLLog(@"NSMessagePort", @"Removing bad name %@", old);
-              [mgr removeFileAtPath: old handler: nil];
-            }
-       }
+        }
       [pool release];
     }
 }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to