mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Improve handling of host/net config errors
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6518 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
09803b00e1
commit
44b8ac3d46
4 changed files with 50 additions and 8 deletions
|
@ -1,8 +1,14 @@
|
||||||
|
2000-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSHost.m: Improve logging of host/net configuration errors
|
||||||
|
* Source/GSTcpPort.m: ditto
|
||||||
|
* Source/TcpPort.m: ditto
|
||||||
|
|
||||||
2000-04-25 Adam Fedor <fedor@gnu.org>
|
2000-04-25 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Source/NSBundle.m (+initialize): retain _executable_path.
|
* Source/NSBundle.m (+initialize): retain _executable_path.
|
||||||
|
|
||||||
2000-04-23 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-04-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSAttributedString.m: Optimised - cache method implementations
|
* Source/NSAttributedString.m: Optimised - cache method implementations
|
||||||
wherever possible in order to avoid objc runtime overheads.
|
wherever possible in order to avoid objc runtime overheads.
|
||||||
|
|
|
@ -1018,13 +1018,18 @@ static NSMapTable *tcpPortMap = 0;
|
||||||
NSHost *thisHost = [NSHost currentHost];
|
NSHost *thisHost = [NSHost currentHost];
|
||||||
NSMapTable *thePorts;
|
NSMapTable *thePorts;
|
||||||
|
|
||||||
|
if (thisHost == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"attempt to create port on host without networking set up!");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
if (aHost == nil)
|
if (aHost == nil)
|
||||||
{
|
{
|
||||||
aHost = thisHost;
|
aHost = thisHost;
|
||||||
}
|
}
|
||||||
if (addr != nil && [[aHost addresses] containsObject: addr] == NO)
|
if (addr != nil && [[aHost addresses] containsObject: addr] == NO)
|
||||||
{
|
{
|
||||||
NSLog(@"attempt to use address '%@' on whost without that address", addr);
|
NSLog(@"attempt to use address '%@' on host without that address", addr);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (number == 0 && [thisHost isEqual: aHost] == NO)
|
if (number == 0 && [thisHost isEqual: aHost] == NO)
|
||||||
|
|
|
@ -69,13 +69,16 @@ static NSMutableDictionary *_hostCache = nil;
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (name == nil)
|
if (name == nil || [name isEqual: @""] == YES)
|
||||||
{
|
{
|
||||||
|
NSLog(@"Host init failed - empty name/address supplied");
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (entry == (struct hostent*)NULL)
|
if (entry == (struct hostent*)NULL)
|
||||||
{
|
{
|
||||||
|
NSLog(@"Host '%@' init failed - perhaps the name/address is wrong or "
|
||||||
|
@"networking is not set up on your machine", name);
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -168,10 +171,18 @@ static NSString *myHost = nil;
|
||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
|
|
||||||
h = gethostbyname((char*)[name cString]);
|
h = gethostbyname((char*)[name cString]);
|
||||||
|
if (h == 0)
|
||||||
|
{
|
||||||
|
NSLog(@"Host '%@' not found using 'gethostbyname()' - perhaps "
|
||||||
|
@"the hostname is wrong or networking is not set up on your "
|
||||||
|
@"machine", name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
host = [[self alloc] _initWithHostEntry: h key: name];
|
host = [[self alloc] _initWithHostEntry: h key: name];
|
||||||
AUTORELEASE(host);
|
AUTORELEASE(host);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
[_hostCacheLock unlock];
|
[_hostCacheLock unlock];
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
@ -213,10 +224,19 @@ static NSString *myHost = nil;
|
||||||
if (addrOk == YES)
|
if (addrOk == YES)
|
||||||
{
|
{
|
||||||
h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET);
|
h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET);
|
||||||
|
if (h == 0)
|
||||||
|
{
|
||||||
|
NSLog(@"Host '%@' not found using 'gethostbyaddr()' - perhaps "
|
||||||
|
@"the address is wrong or networking is not set up on your "
|
||||||
|
@"machine", address);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
host = [[self alloc] _initWithHostEntry: h key: address];
|
host = [[self alloc] _initWithHostEntry: h key: address];
|
||||||
AUTORELEASE(host);
|
AUTORELEASE(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
[_hostCacheLock unlock];
|
[_hostCacheLock unlock];
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,6 +493,12 @@ static NSMapTable* port_number_2_port;
|
||||||
Distributed Objects connection to another machine, they get our
|
Distributed Objects connection to another machine, they get our
|
||||||
unique host address that can identify us across the network. */
|
unique host address that can identify us across the network. */
|
||||||
hostname = [[NSHost currentHost] name];
|
hostname = [[NSHost currentHost] name];
|
||||||
|
if (hostname == nil)
|
||||||
|
{
|
||||||
|
[p release];
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"[TcpInPort +newForReceivingFromPortNumber:] no hostname"];
|
||||||
|
}
|
||||||
hp = gethostbyname ([hostname cString]);
|
hp = gethostbyname ([hostname cString]);
|
||||||
if (!hp)
|
if (!hp)
|
||||||
hp = gethostbyname ("localhost");
|
hp = gethostbyname ("localhost");
|
||||||
|
@ -1233,6 +1239,11 @@ static NSMapTable *out_port_bag = NULL;
|
||||||
if (!hostname || ![hostname length])
|
if (!hostname || ![hostname length])
|
||||||
{
|
{
|
||||||
hostname = [[NSHost currentHost] name];
|
hostname = [[NSHost currentHost] name];
|
||||||
|
if (hostname == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"No local host set upt!");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
host_cstring = [hostname cString];
|
host_cstring = [hostname cString];
|
||||||
hp = gethostbyname ((char*)host_cstring);
|
hp = gethostbyname ((char*)host_cstring);
|
||||||
|
|
Loading…
Reference in a new issue