mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
port mapper updates
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3137 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
58b424e3c8
commit
179714a31b
2 changed files with 189 additions and 142 deletions
62
ChangeLog
62
ChangeLog
|
@ -1,3 +1,11 @@
|
|||
Wed Oct 28 11:00:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Tools/gdomap.c: Added command-line options to lookup, register, and
|
||||
unregister a name for a port - basically for debugging purposes.
|
||||
* src/TcpPort.m: Modified port registration code to cope with the
|
||||
case where a server dies and is restarted, and tries to use the
|
||||
same ip port number it has before it died.
|
||||
|
||||
Tue Oct 27 08:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
Corrected all the collection classes to return the count of objects
|
||||
|
@ -6,29 +14,29 @@ Tue Oct 27 08:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|||
|
||||
Mon Oct 26 10:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSGCString.m: Implemented ([-copy]) and ([-copyWithZone:]) to
|
||||
* src/NSGCString.m: Implemented ([-copy]) and ([-copyWithZone:]) to
|
||||
work without invoking any methods uing the runtime - much faster.
|
||||
src/NSObject.m: Bugfix and performance improvement to the -perform...
|
||||
* src/NSObject.m: Bugfix and performance improvement to the -perform...
|
||||
methods. They previously threw an exception if the method referred
|
||||
to by the selector was not implemented (when they should have tried
|
||||
forwarding instead) rather than when passed a nul selector.
|
||||
|
||||
Sun Oct 25 08:00:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSObject.m: Cache implementation for adding object to autorelease
|
||||
* src/NSObject.m: Cache implementation for adding object to autorelease
|
||||
pool to avoid objc runtime messaging overhead.
|
||||
src/NSAutoreleasePool.m: Cache implementation for adding object to
|
||||
src/NSAutoreleasePool.m: Cache implementation for adding object to
|
||||
* src/NSAutoreleasePool.m: Cache implementation for adding object to
|
||||
* src/NSAutoreleasePool.m: Cache implementation for adding object to
|
||||
autorelease pool to avoid objc runtime messaging overhead.
|
||||
src/NSGCString.m: Implemented ([+allocWithZone:])
|
||||
src/NSGString.m: Implemented ([+allocWithZone:])
|
||||
* src/NSGCString.m: Implemented ([+allocWithZone:])
|
||||
* src/NSGString.m: Implemented ([+allocWithZone:])
|
||||
|
||||
Sat Oct 24 11:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSArchiver.m: New implementation
|
||||
src/NSArchiver.m: New file
|
||||
src/GNUmakefile: Added NSUnarchiver.m
|
||||
src/include/NSArchiver.h: New version
|
||||
* src/NSArchiver.m: New implementation
|
||||
* src/NSArchiver.m: New file
|
||||
* src/GNUmakefile: Added NSUnarchiver.m
|
||||
* src/include/NSArchiver.h: New version
|
||||
New Archiver/unarchiver - OPENSTEP complient (I think).
|
||||
Basic functionality tested fairly thoroughly, some of the more
|
||||
unusual bits untested so far. Mechanisms for adding other backends
|
||||
|
@ -38,29 +46,29 @@ Sat Oct 24 11:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|||
|
||||
Thu Oct 22 21:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSData.m: Added support for serialisation of Class and SEL types
|
||||
* src/NSData.m: Added support for serialisation of Class and SEL types
|
||||
and made a more efficient version of the main deserialisation code
|
||||
int the NSDataStatic class.
|
||||
in the NSDataStatic class.
|
||||
|
||||
Wed Oct 21 13:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSData.m: Reorganized and optimised.
|
||||
src/NSGArray.m: optimised coding/decoding
|
||||
src NSGCountedSet.m: optimised coding/decoding
|
||||
src/NSGDictionary.m: optimised coding/decoding
|
||||
src/NSGSet.m: optimised coding/decoding
|
||||
src/NSObject.m: cache data classes
|
||||
src/NSString.m: Added (nonstandard) ([-boolValue]) method
|
||||
src/include/NSData.h: Added ([-relinquishAllocatedBytesFromZone:])
|
||||
src/include/NSString.h: Added (nonstandard) ([-boolValue]) method
|
||||
src/include/NSPortMessage.h: Added (as yet unused) class.
|
||||
src/NSPortMessage.m: Added (as yet unused) skeleton implementation.
|
||||
* src/NSData.m: Reorganized and optimised.
|
||||
* src/NSGArray.m: optimised coding/decoding
|
||||
* src/NSGCountedSet.m: optimised coding/decoding
|
||||
* src/NSGDictionary.m: optimised coding/decoding
|
||||
* src/NSGSet.m: optimised coding/decoding
|
||||
* src/NSObject.m: cache data classes
|
||||
* src/NSString.m: Added (nonstandard) ([-boolValue]) method
|
||||
* src/include/NSData.h: Added ([-relinquishAllocatedBytesFromZone:])
|
||||
* src/include/NSString.h: Added (nonstandard) ([-boolValue]) method
|
||||
* src/include/NSPortMessage.h: Added (as yet unused) class.
|
||||
* src/NSPortMessage.m: Added (as yet unused) skeleton implementation.
|
||||
|
||||
Thu Oct 17 08:15:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
src/NSGDictionary.m: Added checks for invalid parameters.
|
||||
src/NSGSet.m: Added checks for invalid parameters.
|
||||
src/NSGCountedSet.m: Added checks for invalid parameters.
|
||||
* src/NSGDictionary.m: Added checks for invalid parameters.
|
||||
* src/NSGSet.m: Added checks for invalid parameters.
|
||||
* src/NSGCountedSet.m: Added checks for invalid parameters.
|
||||
|
||||
Thu Oct 15 08:13:12 1998 Masatake Yamato <masata-y@is.aist-nara.ac.jp>
|
||||
|
||||
|
|
269
Source/TcpPort.m
269
Source/TcpPort.m
|
@ -502,159 +502,198 @@ nameFail(int why)
|
|||
static int
|
||||
nameServer(const char* name, const char* host, int op, struct sockaddr_in* addr, int pnum, int max)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
struct servent* sp;
|
||||
struct hostent* hp;
|
||||
unsigned short p = htons(GDOMAP_PORT);
|
||||
unsigned short port = 0;
|
||||
int len = strlen(name);
|
||||
int multi = 0;
|
||||
int found = 0;
|
||||
int rval;
|
||||
char local_hostname[MAXHOSTNAMELEN];
|
||||
struct sockaddr_in sin;
|
||||
struct servent* sp;
|
||||
struct hostent* hp;
|
||||
unsigned short p = htons(GDOMAP_PORT);
|
||||
unsigned short port = 0;
|
||||
int len = strlen(name);
|
||||
int multi = 0;
|
||||
int found = 0;
|
||||
int rval;
|
||||
char local_hostname[MAXHOSTNAMELEN];
|
||||
|
||||
if (len == 0) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"no name specified"];
|
||||
if (len == 0)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"no name specified"];
|
||||
}
|
||||
if (len > 255) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"name length to large (>255 characters)"];
|
||||
if (len > 255)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"name length to large (>255 characters)"];
|
||||
}
|
||||
|
||||
#if GDOMAP_PORT_OVERRIDE
|
||||
p = htons(GDOMAP_PORT_OVERRIDE);
|
||||
p = htons(GDOMAP_PORT_OVERRIDE);
|
||||
#else
|
||||
/*
|
||||
* Ensure we have port number to connect to name server.
|
||||
* The TCP service name 'gdomap' overrides the default port.
|
||||
*/
|
||||
if ((sp = getservbyname("gdomap", "tcp")) != 0) {
|
||||
p = sp->s_port; /* Network byte order. */
|
||||
/*
|
||||
* Ensure we have port number to connect to name server.
|
||||
* The TCP service name 'gdomap' overrides the default port.
|
||||
*/
|
||||
if ((sp = getservbyname("gdomap", "tcp")) != 0)
|
||||
{
|
||||
p = sp->s_port; /* Network byte order. */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The host name '*' matches any host on the local network.
|
||||
*/
|
||||
if (host && host[0] == '*' && host[1] == '\0') {
|
||||
multi = 1;
|
||||
/*
|
||||
* The host name '*' matches any host on the local network.
|
||||
*/
|
||||
if (host && host[0] == '*' && host[1] == '\0')
|
||||
{
|
||||
multi = 1;
|
||||
}
|
||||
/*
|
||||
* If no host name is given, we use the name of the local host.
|
||||
* NB. This should always be the case for operations other than lookup.
|
||||
*/
|
||||
if (multi || host == 0 || *host == '\0') {
|
||||
char *first_dot;
|
||||
/*
|
||||
* If no host name is given, we use the name of the local host.
|
||||
* NB. This should always be the case for operations other than lookup.
|
||||
*/
|
||||
if (multi || host == 0 || *host == '\0')
|
||||
{
|
||||
char *first_dot;
|
||||
|
||||
if (gethostname(local_hostname, sizeof(local_hostname)) < 0) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"gethostname() failed: %s", strerror(errno)];
|
||||
if (gethostname(local_hostname, sizeof(local_hostname)) < 0)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"gethostname() failed: %s", strerror(errno)];
|
||||
}
|
||||
first_dot = strchr(local_hostname, '.');
|
||||
if (first_dot) {
|
||||
*first_dot = '\0';
|
||||
first_dot = strchr(local_hostname, '.');
|
||||
if (first_dot)
|
||||
{
|
||||
*first_dot = '\0';
|
||||
}
|
||||
host = local_hostname;
|
||||
host = local_hostname;
|
||||
}
|
||||
if ((hp = gethostbyname(host)) == 0) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"get host address for %s", host];
|
||||
if ((hp = gethostbyname(host)) == 0)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"get host address for %s", host];
|
||||
}
|
||||
if (hp->h_addrtype != AF_INET) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"non-internet network not supported for %s", host];
|
||||
if (hp->h_addrtype != AF_INET)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"non-internet network not supported for %s", host];
|
||||
}
|
||||
|
||||
memset((char*)&sin, '\0', sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = p;
|
||||
memcpy((caddr_t)&sin.sin_addr, hp->h_addr, hp->h_length);
|
||||
memset((char*)&sin, '\0', sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = p;
|
||||
memcpy((caddr_t)&sin.sin_addr, hp->h_addr, hp->h_length);
|
||||
|
||||
if (multi) {
|
||||
unsigned short num;
|
||||
struct in_addr* b;
|
||||
if (multi)
|
||||
{
|
||||
unsigned short num;
|
||||
struct in_addr* b;
|
||||
|
||||
/*
|
||||
* A host name of '*' is a special case which should do lookup on
|
||||
* all machines on the local network until one is found which has
|
||||
* the specified server on it.
|
||||
*/
|
||||
rval = tryHost(GDO_SERVERS, 0, 0, &sin, &num, (unsigned char**)&b);
|
||||
/*
|
||||
* If the connection to the local name server fails,
|
||||
* attempt to start it us and retry the lookup.
|
||||
*/
|
||||
if (rval != 0 && host == local_hostname) {
|
||||
system(make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX));
|
||||
sleep(5);
|
||||
rval = tryHost(GDO_SERVERS, 0, 0, &sin, &num, (unsigned char**)&b);
|
||||
/*
|
||||
* A host name of '*' is a special case which should do lookup on
|
||||
* all machines on the local network until one is found which has
|
||||
* the specified server on it.
|
||||
*/
|
||||
rval = tryHost(GDO_SERVERS, 0, 0, &sin, &num, (unsigned char**)&b);
|
||||
/*
|
||||
* If the connection to the local name server fails,
|
||||
* attempt to start it us and retry the lookup.
|
||||
*/
|
||||
if (rval != 0 && host == local_hostname)
|
||||
{
|
||||
system(make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX));
|
||||
sleep(5);
|
||||
rval = tryHost(GDO_SERVERS, 0, 0, &sin, &num, (unsigned char**)&b);
|
||||
}
|
||||
if (rval == 0) {
|
||||
int i;
|
||||
if (rval == 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; found == 0 && i < num; i++) {
|
||||
memset((char*)&sin, '\0', sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = p;
|
||||
memcpy((caddr_t)&sin.sin_addr, &b[i], sizeof(struct in_addr));
|
||||
if (sin.sin_addr.s_addr == 0) continue;
|
||||
for (i = 0; found == 0 && i < num; i++)
|
||||
{
|
||||
memset((char*)&sin, '\0', sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = p;
|
||||
memcpy((caddr_t)&sin.sin_addr, &b[i], sizeof(struct in_addr));
|
||||
if (sin.sin_addr.s_addr == 0)
|
||||
continue;
|
||||
|
||||
if (tryHost(GDO_LOOKUP, len, name, &sin, &port, 0) == 0) {
|
||||
if (port != 0) {
|
||||
memset((char*)&addr[found], '\0', sizeof(*addr));
|
||||
memcpy((caddr_t)&addr[found].sin_addr, &sin.sin_addr,
|
||||
if (tryHost(GDO_LOOKUP, len, name, &sin, &port, 0) == 0)
|
||||
{
|
||||
if (port != 0)
|
||||
{
|
||||
memset((char*)&addr[found], '\0', sizeof(*addr));
|
||||
memcpy((caddr_t)&addr[found].sin_addr, &sin.sin_addr,
|
||||
sizeof(sin.sin_addr));
|
||||
addr[found].sin_family = AF_INET;
|
||||
addr[found].sin_port = htons(port);
|
||||
found++;
|
||||
if (found == max) {
|
||||
break;
|
||||
addr[found].sin_family = AF_INET;
|
||||
addr[found].sin_port = htons(port);
|
||||
found++;
|
||||
if (found == max)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
objc_free(b);
|
||||
return(found);
|
||||
objc_free(b);
|
||||
return(found);
|
||||
}
|
||||
else {
|
||||
nameFail(rval);
|
||||
else
|
||||
{
|
||||
nameFail(rval);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (op == GDO_REGISTER) {
|
||||
port = (unsigned short)pnum;
|
||||
else
|
||||
{
|
||||
if (op == GDO_REGISTER)
|
||||
{
|
||||
port = (unsigned short)pnum;
|
||||
}
|
||||
rval = tryHost(op, len, name, &sin, &port, 0);
|
||||
/*
|
||||
* If the connection to the local name server fails,
|
||||
* attempt to start it us and retry the lookup.
|
||||
*/
|
||||
if (rval != 0 && host == local_hostname) {
|
||||
system(make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX));
|
||||
sleep(5);
|
||||
if (op == GDO_REGISTER) {
|
||||
port = (unsigned short)pnum;
|
||||
rval = tryHost(op, len, name, &sin, &port, 0);
|
||||
/*
|
||||
* If the connection to the local name server fails,
|
||||
* attempt to start it us and retry the lookup.
|
||||
*/
|
||||
if (rval != 0 && host == local_hostname)
|
||||
{
|
||||
system(make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX));
|
||||
sleep(5);
|
||||
if (op == GDO_REGISTER)
|
||||
{
|
||||
port = (unsigned short)pnum;
|
||||
}
|
||||
rval = tryHost(op, len, name, &sin, &port, 0);
|
||||
rval = tryHost(op, len, name, &sin, &port, 0);
|
||||
}
|
||||
nameFail(rval);
|
||||
nameFail(rval);
|
||||
}
|
||||
|
||||
if (op == GDO_REGISTER) {
|
||||
if (port == 0 || (pnum != 0 && port != pnum)) {
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"service already registered"];
|
||||
if (op == GDO_REGISTER)
|
||||
{
|
||||
if (port == 0 || (pnum != 0 && port != pnum))
|
||||
{
|
||||
/*
|
||||
* If the name server thinks we are already registered on this
|
||||
* port, we must have crashed, restarted, and got the same port
|
||||
* number we used to have before we crashed. The solution is to
|
||||
* unregister our name from the port and retry the registration.
|
||||
*/
|
||||
rval = tryHost(GDO_UNREG, len, name, &sin, &port, 0);
|
||||
nameFail(rval);
|
||||
port = (unsigned short)pnum;
|
||||
rval = tryHost(op, len, name, &sin, &port, 0);
|
||||
nameFail(rval);
|
||||
if (port == 0 || (pnum != 0 && port != pnum))
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"service already registered"];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (port == 0) {
|
||||
return 0;
|
||||
if (port == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memset((char*)addr, '\0', sizeof(*addr));
|
||||
memcpy((caddr_t)&addr->sin_addr, &sin.sin_addr, sizeof(sin.sin_addr));
|
||||
addr->sin_family = AF_INET;
|
||||
addr->sin_port = htons(port);
|
||||
return 1;
|
||||
memset((char*)addr, '\0', sizeof(*addr));
|
||||
memcpy((caddr_t)&addr->sin_addr, &sin.sin_addr, sizeof(sin.sin_addr));
|
||||
addr->sin_family = AF_INET;
|
||||
addr->sin_port = htons(port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue