mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-15 08:01:42 +00:00
Use well known host name more consistenctly
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/devmodules/dev-libs/ec@35147 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6a196d1400
commit
c0ca42ec76
3 changed files with 33 additions and 14 deletions
|
@ -35,6 +35,7 @@
|
|||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import "EcHost.h"
|
||||
#import "EcProcess.h"
|
||||
#import "EcAlarm.h"
|
||||
|
||||
|
@ -48,7 +49,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
|||
|
||||
if (nil == host)
|
||||
{
|
||||
host = [[NSHost currentHost] name];
|
||||
host = [[NSHost currentHost] wellKnownName];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <GNUstepBase/GSMime.h>
|
||||
|
||||
#import "EcHost.h"
|
||||
#import "EcProcess.h"
|
||||
#import "EcAlerter.h"
|
||||
#import "NSFileHandle+Printf.h"
|
||||
|
@ -393,7 +394,7 @@ replaceFields(NSDictionary *fields)
|
|||
if (nil == eFrom)
|
||||
{
|
||||
eFrom = [NSString stringWithFormat: @"alerter@%@",
|
||||
[[NSHost currentHost] name]];
|
||||
[[NSHost currentHost] wellKnownName]];
|
||||
RETAIN(eFrom);
|
||||
}
|
||||
|
||||
|
|
41
EcProcess.m
41
EcProcess.m
|
@ -354,18 +354,24 @@ cmdLogKey(EcLogType t)
|
|||
NSString*
|
||||
cmdLogName()
|
||||
{
|
||||
static NSString *n = nil;
|
||||
static NSString *cmdLogName = nil;
|
||||
|
||||
if (n == nil)
|
||||
if (nil == cmdLogName)
|
||||
{
|
||||
n = [EcProc cmdName];
|
||||
if (n == nil)
|
||||
[ecLock lock];
|
||||
if (nil == cmdLogName)
|
||||
{
|
||||
n = [[NSProcessInfo processInfo] processName];
|
||||
NSString *n = [EcProc cmdName];
|
||||
|
||||
if (nil == n)
|
||||
{
|
||||
n = [[NSProcessInfo processInfo] processName];
|
||||
}
|
||||
cmdLogName = [n copy];
|
||||
}
|
||||
n = [n copy];
|
||||
[ecLock unlock];
|
||||
}
|
||||
return n;
|
||||
return cmdLogName;
|
||||
}
|
||||
|
||||
NSString*
|
||||
|
@ -381,7 +387,7 @@ cmdLogFormat(EcLogType t, NSString *fmt)
|
|||
|
||||
if (h == nil)
|
||||
{
|
||||
h = [[[NSHost currentHost] name] copy];
|
||||
h = [[[NSHost currentHost] wellKnownName] copy];
|
||||
}
|
||||
if (l == nil)
|
||||
{
|
||||
|
@ -433,6 +439,16 @@ static NSMutableArray *updateHandlers = nil;
|
|||
static NSMutableDictionary *servers = nil;
|
||||
|
||||
static NSString *hostName = nil;
|
||||
static NSString *
|
||||
ecHostName()
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
[ecLock lock];
|
||||
name = [hostName retain];
|
||||
[ecLock unlock];
|
||||
return [name autorelease];
|
||||
}
|
||||
|
||||
#define DEFMEMALLOWED 50
|
||||
static int memAllowed = DEFMEMALLOWED;
|
||||
|
@ -1064,6 +1080,7 @@ static NSString *noFiles = @"No log files to archive";
|
|||
if (nil != dict)
|
||||
{
|
||||
[NSHost setWellKnownNames: dict];
|
||||
ASSIGN(hostName, [[NSHost currentHost] wellKnownName]);
|
||||
}
|
||||
|
||||
GSDebugAllocationActive([cmdDefs boolForKey: @"Memory"]);
|
||||
|
@ -1332,7 +1349,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
stringClass = [NSString class];
|
||||
cmdLogMap = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||
|
||||
hostName = RETAIN([[NSHost currentHost] name]);
|
||||
hostName = [[[NSHost currentHost] wellKnownName] retain];
|
||||
|
||||
cmdDebugModes = [[NSMutableSet alloc] initWithCapacity: 4];
|
||||
cmdDebugKnown = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||
|
@ -2534,7 +2551,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
else
|
||||
{
|
||||
[self cmdPrintf: @"\n%@ on %@ running since %@\n\n",
|
||||
cmdLogName(), hostName, [self cmdStarted]];
|
||||
cmdLogName(), ecHostName(), [self cmdStarted]];
|
||||
|
||||
if (NO == [cmdDefs boolForKey: @"Memory"])
|
||||
{
|
||||
|
@ -2560,7 +2577,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
else
|
||||
{
|
||||
[self cmdPrintf: @"\n%@ on %@ running since %@\n",
|
||||
cmdLogName(), hostName, [self cmdStarted]];
|
||||
cmdLogName(), ecHostName(), [self cmdStarted]];
|
||||
if ([self cmdLastIP] != nil)
|
||||
{
|
||||
[self cmdPrintf: @"Last IP at %@\n", [self cmdLastIP]];
|
||||
|
@ -2795,7 +2812,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
- (NSString*) description
|
||||
{
|
||||
return [stringClass stringWithFormat: @"%@ (%@) on %@",
|
||||
[super description], cmdLogName(), hostName];
|
||||
[super description], cmdLogName(), ecHostName()];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
|
|
Loading…
Reference in a new issue