diff --git a/ChangeLog b/ChangeLog index e2a040a8c..d426f8025 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jan 21 17:37:00 1998 Richard Frith-Macdonald + + * Tools/defaults.m: Fixed bug in handling 'write' operations reading + info from stdin - now puts all values into the database correctly. + + * src/TcpPort.m: ([+newForReceivingFromPortNumber:]) added code to + perform retries if the kernel freaks out when asked to select the + port to bind to - this has happened to me on linux! + Wed Jan 21 11:45:00 1998 Richard Frith-Macdonald * src/GetDefEncoding.m: Modified GetDefEncoding() to us the NSString diff --git a/Source/TcpPort.m b/Source/TcpPort.m index c9c1118bc..9b99e94b4 100644 --- a/Source/TcpPort.m +++ b/Source/TcpPort.m @@ -752,9 +752,31 @@ static NSMapTable* port_number_2_port; sizeof (p->_listening_address)) < 0) { - [NSException raise: NSInternalInconsistencyException - format: @"[TcpInPort +newForReceivingFromPortNumber:] bind(): %s", - strerror(errno)]; + BOOL ok = NO; + /* bind() sometimes seems to fail when given a port of zero - this + * should really never happen, so we retry a few times in case the + * kernel has had a temporary brainstorm. + */ + if (n == 0) { + int count; + + for (count = 0; count < 10; count++) { + memset(&p->_listening_address, 0, sizeof(p->_listening_address)); + p->_listening_address.sin_addr.s_addr = htonl (INADDR_ANY); + p->_listening_address.sin_family = AF_INET; + if (bind (p->_port_socket, + (struct sockaddr*) &(p->_listening_address), + sizeof (p->_listening_address)) == 0) { + ok = YES; + break; + } + } + } + if (ok == NO) { + [NSException raise: NSInternalInconsistencyException + format: @"[TcpInPort +newForReceivingFromPortNumber:] bind(): %s", + strerror(errno)]; + } } /* If the caller didn't specify a port number, it was chosen for us. diff --git a/Tools/defaults.m b/Tools/defaults.m index 4c61e6bbb..ca7a48e7d 100644 --- a/Tools/defaults.m +++ b/Tools/defaults.m @@ -427,6 +427,7 @@ property list which is set as the value of a default.\n\n"); domain = [NSMutableDictionary dictionaryWithCapacity:1]; } [domain setObject: obj forKey: name]; + [defs setPersistentDomain: domain forName: owner]; } } else { @@ -469,8 +470,8 @@ property list which is set as the value of a default.\n\n"); exit(0); } } + [defs setPersistentDomain: domain forName: owner]; } - [defs setPersistentDomain: domain forName: owner]; if ([defs synchronize] == NO) { NSLog(@"defaults: unable to write to defaults database - %s\n",