mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
DO patch from Frith-Macdonald. Makefile changes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2659 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
92afd78cda
commit
291fe068aa
13 changed files with 268 additions and 60 deletions
|
@ -223,3 +223,6 @@ copy-dist: $(DIST_FILES)
|
|||
ln $$file ../snap/src/include/`basename $$file` ; \
|
||||
done
|
||||
ln AUTHORS ../snap
|
||||
|
||||
FORCE:
|
||||
|
||||
|
|
|
@ -359,6 +359,18 @@ static int messages_received_count;
|
|||
return newConn;
|
||||
}
|
||||
|
||||
/* xxx This method is an anomaly, just until we get a proper name
|
||||
server for port objects. Richard Frith-MacDonald is working on a
|
||||
name server. */
|
||||
- (BOOL) registerName: (NSString*)name
|
||||
{
|
||||
id old_receive_port = receive_port;
|
||||
receive_port = [default_receive_port_class newForReceivingFromRegisteredName: name];
|
||||
[old_receive_port release];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Keep track of connections created by DO system but not necessarily
|
||||
* ever retained by users code. These must be retained now for later
|
||||
|
@ -737,18 +749,6 @@ static int messages_received_count;
|
|||
return newRemote;
|
||||
}
|
||||
|
||||
/* xxx This method is an anomaly, just until we get a proper name
|
||||
server for port objects. Richard Frith-MacDonald is working on a
|
||||
name server. */
|
||||
- (BOOL) registerName: (NSString*)name
|
||||
{
|
||||
id old_receive_port = receive_port;
|
||||
receive_port = [default_receive_port_class newForReceivingFromRegisteredName: name];
|
||||
[old_receive_port release];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This is the designated initializer for NSConnection */
|
||||
|
||||
|
@ -756,28 +756,15 @@ static int messages_received_count;
|
|||
ancestorConnection: ancestor
|
||||
{
|
||||
NSConnection *newConn;
|
||||
int i, count;
|
||||
id newConnInPort, newConnOutPort;
|
||||
|
||||
NSParameterAssert (ip);
|
||||
|
||||
[connection_array_gate lock];
|
||||
|
||||
/* Find previously existing connection if there */
|
||||
/* xxx Clean this up */
|
||||
count = [connection_array count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
newConn = [connection_array objectAtIndex: i];
|
||||
newConnInPort = [newConn receivePort];
|
||||
newConnOutPort = [newConn sendPort];
|
||||
if ([newConnInPort isEqual: ip]
|
||||
&& [newConnOutPort isEqual: op])
|
||||
{
|
||||
[connection_array_gate unlock];
|
||||
return [newConn retain];
|
||||
}
|
||||
}
|
||||
newConn = [[self connectionByInPort: ip outPort: op] retain];
|
||||
if (newConn)
|
||||
return newConn;
|
||||
|
||||
[connection_array_gate lock];
|
||||
|
||||
newConn = [[NSConnection alloc] _superInit];
|
||||
if (debug_connection)
|
||||
|
@ -920,6 +907,62 @@ static int messages_received_count;
|
|||
return newConn;
|
||||
}
|
||||
|
||||
+ (NSConnection*) connectionByInPort: (NSPort*)ip
|
||||
outPort: (NSPort*)op
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
|
||||
NSParameterAssert (ip);
|
||||
|
||||
[connection_array_gate lock];
|
||||
count = [connection_array count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
id newConnInPort;
|
||||
id newConnOutPort;
|
||||
NSConnection *newConn;
|
||||
|
||||
newConn = [connection_array objectAtIndex: i];
|
||||
newConnInPort = [newConn receivePort];
|
||||
newConnOutPort = [newConn sendPort];
|
||||
if ([newConnInPort isEqual: ip]
|
||||
&& [newConnOutPort isEqual: op])
|
||||
{
|
||||
[connection_array_gate unlock];
|
||||
return newConn;
|
||||
}
|
||||
}
|
||||
[connection_array_gate unlock];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSConnection*) connectionByOutPort: (NSPort*)op
|
||||
{
|
||||
int i, count;
|
||||
|
||||
NSParameterAssert (op);
|
||||
|
||||
[connection_array_gate lock];
|
||||
|
||||
count = [connection_array count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
id newConnOutPort;
|
||||
NSConnection *newConn;
|
||||
|
||||
newConn = [connection_array objectAtIndex: i];
|
||||
newConnOutPort = [newConn sendPort];
|
||||
if ([newConnOutPort isEqual: op])
|
||||
{
|
||||
[connection_array_gate unlock];
|
||||
return newConn;
|
||||
}
|
||||
}
|
||||
[connection_array_gate unlock];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- _superInit
|
||||
{
|
||||
[super init];
|
||||
|
@ -1245,6 +1288,30 @@ static int messages_received_count;
|
|||
[rmc dismiss];
|
||||
}
|
||||
|
||||
- (void) _service_retain: rmc forConnection: receiving_connection
|
||||
{
|
||||
unsigned int target;
|
||||
|
||||
NSParameterAssert (is_valid);
|
||||
|
||||
if ([rmc connection] != self) {
|
||||
[NSException raise: @"ProxyDecodedBadTarget"
|
||||
format: @"request to retain object on bad connection"];
|
||||
}
|
||||
|
||||
[rmc decodeValueOfCType: @encode(typeof(target))
|
||||
at: &target
|
||||
withName: NULL];
|
||||
|
||||
if ([self includesLocalObject:(void*)target] == NO) {
|
||||
if ([[self class] includesLocalObject:(void*)target] == YES) {
|
||||
[NSDistantObject proxyWithLocal: (id)target connection: self];
|
||||
}
|
||||
}
|
||||
|
||||
[rmc dismiss];
|
||||
}
|
||||
|
||||
- (void) shutdown
|
||||
{
|
||||
id op;
|
||||
|
@ -1416,6 +1483,11 @@ static int messages_received_count;
|
|||
[conn _service_release: rmc forConnection: self];
|
||||
break;
|
||||
}
|
||||
case PROXY_RETAIN:
|
||||
{
|
||||
[conn _service_retain: rmc forConnection: self];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
[conn release];
|
||||
[NSException raise: NSGenericException
|
||||
|
@ -1641,6 +1713,39 @@ static int messages_received_count;
|
|||
NS_ENDHANDLER
|
||||
}
|
||||
|
||||
- (void) retainTarget: (unsigned int)target
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
/*
|
||||
* Tell the remote app that it must retain the local object
|
||||
* for the target on this connection.
|
||||
*/
|
||||
if (receive_port && is_valid) {
|
||||
id op;
|
||||
unsigned int i;
|
||||
|
||||
op = [[self encodingClass]
|
||||
newForWritingWithConnection: self
|
||||
sequenceNumber: [self _newMsgNumber]
|
||||
identifier: PROXY_RETAIN];
|
||||
|
||||
[op encodeValueOfCType: @encode(typeof(target))
|
||||
at: &target
|
||||
withName: NULL];
|
||||
|
||||
[op dismiss];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
if (debug_connection)
|
||||
fprintf (stderr, "failed to retain target - %s\n",
|
||||
[[localException name] cStringNoCopy]);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
|
||||
- (void) removeProxy: (NSDistantObject*)aProxy
|
||||
{
|
||||
unsigned target = (unsigned)[aProxy targetForProxy];
|
||||
|
|
|
@ -415,6 +415,7 @@ format: @"NSDistantObject objects only decode with PortDecoder class"];
|
|||
* inPort/outPort pair, or create a new connection if necessary.
|
||||
*/
|
||||
{
|
||||
NSDistantObject *result;
|
||||
NSConnection *proxy_connection;
|
||||
NSPort* proxy_connection_out_port = nil;
|
||||
|
||||
|
@ -426,7 +427,27 @@ format: @"NSDistantObject objects only decode with PortDecoder class"];
|
|||
withName: NULL];
|
||||
|
||||
assert (proxy_connection_out_port);
|
||||
/* xxx - if there already exists a connection for talking to the
|
||||
* out port, we use that one rather than creating a new one from
|
||||
* our listening port.
|
||||
*
|
||||
* First we try for a connection from our receive port,
|
||||
* Then we try any connection to the send port
|
||||
* Finally we resort to creating a new connection - we don't
|
||||
* release the newly created connection - it will get released
|
||||
* automatically when no proxies are left on it.
|
||||
*/
|
||||
proxy_connection = [[decoder_connection class]
|
||||
connectionByInPort:
|
||||
[decoder_connection receivePort]
|
||||
outPort:
|
||||
proxy_connection_out_port];
|
||||
if (proxy_connection == nil)
|
||||
proxy_connection = [[decoder_connection class]
|
||||
connectionByOutPort:
|
||||
proxy_connection_out_port];
|
||||
if (proxy_connection == nil)
|
||||
proxy_connection = [[decoder_connection class]
|
||||
newForInPort: [decoder_connection receivePort]
|
||||
outPort: proxy_connection_out_port
|
||||
ancestorConnection: decoder_connection];
|
||||
|
@ -438,8 +459,17 @@ format: @"NSDistantObject objects only decode with PortDecoder class"];
|
|||
assert (proxy_connection != decoder_connection);
|
||||
assert ([proxy_connection isValid]);
|
||||
|
||||
return [[NSDistantObject proxyWithTarget: (id)target
|
||||
/*
|
||||
* If we don't already have a proxy for the object on the
|
||||
* remote system, we must tell the other end to retain its
|
||||
* local object for our use.
|
||||
*/
|
||||
if ([proxy_connection includesProxyForTarget: target] == NO)
|
||||
[proxy_connection retainTarget: target];
|
||||
|
||||
result = [[NSDistantObject proxyWithTarget: (id)target
|
||||
connection: proxy_connection] retain];
|
||||
return result;
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -71,9 +71,6 @@ static NSString* GNU_UserDefaultsDatabaseLock = @"GNUstep/.GNUstepUDLock";
|
|||
*** Class variables
|
||||
*************************************************************************/
|
||||
static NSUserDefaults *sharedDefaults = nil;
|
||||
static NSMutableString *defaultsDatabase = nil;
|
||||
static NSMutableString *defaultsDatabaseLockName = nil;
|
||||
static NSDistributedLock *defaultsDatabaseLock = nil;
|
||||
static NSMutableString *processName = nil;
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -165,10 +162,11 @@ static NSMutableString *processName = nil;
|
|||
// Either userName is empty or it's wrong
|
||||
if (!userHome)
|
||||
{
|
||||
[self release]; /* xxx really? -mccallum. */
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
filename = [userHome stringByAppendingString: GNU_UserDefaultsDatabase];
|
||||
filename = [NSString stringWithFormat: @"%@/%@",
|
||||
userHome, GNU_UserDefaultsDatabase];
|
||||
return [self initWithContentsOfFile: filename];
|
||||
}
|
||||
|
||||
|
@ -181,21 +179,31 @@ static NSMutableString *processName = nil;
|
|||
// Find the user's home folder and build the paths (executed only once)
|
||||
if (!defaultsDatabase)
|
||||
{
|
||||
defaultsDatabase =
|
||||
if (path != nil && [path isEqual: @""] == NO)
|
||||
defaultsDatabase = [path copy];
|
||||
else
|
||||
defaultsDatabase =
|
||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||
NSHomeDirectoryForUser(NSUserName()),
|
||||
GNU_UserDefaultsDatabase] retain];
|
||||
defaultsDatabaseLockName =
|
||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||
|
||||
if ([[defaultsDatabase lastPathComponent] isEqual:
|
||||
[GNU_UserDefaultsDatabase lastPathComponent]] == YES)
|
||||
defaultsDatabaseLockName =
|
||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||
[defaultsDatabase stringByDeletingLastPathComponent],
|
||||
[GNU_UserDefaultsDatabaseLock lastPathComponent]]
|
||||
retain];
|
||||
else
|
||||
defaultsDatabaseLockName =
|
||||
[[NSMutableString stringWithFormat:@"%@/%@",
|
||||
NSHomeDirectoryForUser(NSUserName()),
|
||||
GNU_UserDefaultsDatabaseLock] retain];
|
||||
defaultsDatabaseLock =
|
||||
[[NSDistributedLock lockWithPath: defaultsDatabaseLockName] retain];
|
||||
processName = [[[NSProcessInfo processInfo] processName] retain];
|
||||
#if 0
|
||||
processName = [[NSMutableString stringWithFormat:@"TestApp"] retain];
|
||||
#endif
|
||||
}
|
||||
if (processName == nil)
|
||||
processName = [[[NSProcessInfo processInfo] processName] retain];
|
||||
|
||||
// Create an empty search list
|
||||
searchList = [[NSMutableArray arrayWithCapacity:10] retain];
|
||||
|
@ -468,12 +476,13 @@ static NSMutableString *processName = nil;
|
|||
|
||||
tickingTimer = NO;
|
||||
|
||||
// Get file lock
|
||||
// Get file lock - break any lock that is more than five minute old.
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
if ([[defaultsDatabaseLock lockDate] timeIntervalSinceNow] < 300.0)
|
||||
{
|
||||
NSLog(@"unable to access defaults database - locked on (%@) since %@\n",
|
||||
defaultsDatabaseLockName, [defaultsDatabaseLock lockDate]);
|
||||
return NO;
|
||||
[defaultsDatabaseLock breakLock];
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Read the persistent data from the stored database
|
||||
|
@ -484,7 +493,7 @@ static NSMutableString *processName = nil;
|
|||
initWithCapacity:1];
|
||||
|
||||
if (changedDomains)
|
||||
{ // Synchronize bpth dictionaries
|
||||
{ // Synchronize both dictionaries
|
||||
NSEnumerator *enumerator = [changedDomains objectEnumerator];
|
||||
id obj, dict;
|
||||
|
||||
|
@ -501,7 +510,7 @@ static NSMutableString *processName = nil;
|
|||
// Save the changes
|
||||
if (![persDomains writeToFile:defaultsDatabase atomically:YES])
|
||||
{
|
||||
NSLog(@"failed to write defaults to '%@'\n", defaultsDatabase);
|
||||
// NSLog(@"failed to write defaults to '%@'\n", defaultsDatabase);
|
||||
[defaultsDatabaseLock unlock];
|
||||
return NO;
|
||||
}
|
||||
|
|
|
@ -212,12 +212,12 @@ _ostream_new_stream_struct (int mode, char** cmode)
|
|||
stream->flags |= OSTREAM_WRITEFLAG;
|
||||
break;
|
||||
case OSTREAM_READWRITE:
|
||||
fmode = "w+";
|
||||
fmode = "r+";
|
||||
stream->flags |= OSTREAM_READFLAG;
|
||||
stream->flags |= OSTREAM_WRITEFLAG;
|
||||
break;
|
||||
case OSTREAM_APPEND:
|
||||
fmode = "w";
|
||||
fmode = "r+";
|
||||
stream->flags |= OSTREAM_WRITEFLAG;
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue