Fixes from Frith-MacDonald

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2768 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1998-03-05 00:37:44 +00:00
parent 192d0c8cb9
commit 70a2dc2b65
5 changed files with 65 additions and 17 deletions

View file

@ -1,6 +1,22 @@
Wed Mar 4 17:11:23 1998 Adam Fedor <fedor@doc.com>
* Version: Version 0.5.0;
Wed Mar 4 21:06:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/NSConnection.m: Changed some objects to be OpenStep rather than
old libobjects types. Using NSMutableArray rather than Queue for the
message queues seems to fixes bug with queue corruption under heavy
load.
* src/NSHost.m: Added methods for archiving NSHost objects and
sending them bycopy over DO at all times.
* src/NSRunLoop.m: ([-runUntilDate:forMode:]) modified to exit
promptly if there are no more input sources for the run loop.
Mon Mar 2 10:04:57 1998 Adam Fedor <fedor@doc.com>
* Version: Version 0.5.0.
* ANNOUNCE, NEWS, GNUstep-HOWTO: Update.
* doc/faq.tmpl.texi, doc/gnustep-howto.tmpl.texi,
doc/news.tmpl.texi: Likewise.

View file

@ -34,13 +34,11 @@
#include <gnustep/base/preface.h>
#include <Foundation/DistributedObjects.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/Array.h>
#include <gnustep/base/Dictionary.h>
#include <gnustep/base/Queue.h>
#include <gnustep/base/mframe.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/MallocAddress.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSString.h>
@ -182,7 +180,7 @@ static NSMutableArray *connection_array;
static NSMutableArray *not_owned;
static Lock *connection_array_gate;
static Dictionary *root_object_dictionary;
static NSMutableDictionary *root_object_dictionary;
static Lock *root_object_dictionary_gate;
static NSMapTable *receive_port_2_ancestor;
@ -190,9 +188,9 @@ static NSMapTable *receive_port_2_ancestor;
static NSMapTable *all_connections_local_targets = NULL;
/* rmc handling */
static Queue *received_request_rmc_queue;
static NSMutableArray *received_request_rmc_queue;
static Lock *received_request_rmc_queue_gate;
static Queue *received_reply_rmc_queue;
static NSMutableArray *received_reply_rmc_queue;
static Lock *received_reply_rmc_queue_gate;
static int messages_received_count;
@ -258,11 +256,11 @@ static int messages_received_count;
all_connections_local_targets =
NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
received_request_rmc_queue = [[Queue alloc] init];
received_request_rmc_queue = [[NSMutableArray alloc] initWithCapacity:32];
received_request_rmc_queue_gate = [Lock new];
received_reply_rmc_queue = [[Queue alloc] init];
received_reply_rmc_queue = [[NSMutableArray alloc] initWithCapacity:32];
received_reply_rmc_queue_gate = [Lock new];
root_object_dictionary = [[Dictionary alloc] init];
root_object_dictionary = [[NSMutableDictionary alloc] initWithCapacity:8];
root_object_dictionary_gate = [Lock new];
receive_port_2_ancestor =
NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
@ -1444,7 +1442,7 @@ static int messages_received_count;
If the REPLY_DEPTH is 0, then we aren't in the middle of waiting
for a reply, we are waiting for requests---so service it now.
If REPLY_DEPTH is non-zero, we may still want to service it now
unless we have independant_queueing set. */
if independant_queuing is NO. */
if (reply_depth == 0 || independant_queueing == NO)
{
[self retain];
@ -1459,7 +1457,7 @@ static int messages_received_count;
else
{
[received_request_rmc_queue_gate lock];
[received_request_rmc_queue enqueueObject: rmc];
[received_request_rmc_queue addObject: rmc];
[received_request_rmc_queue_gate unlock];
}
break;
@ -1468,7 +1466,7 @@ static int messages_received_count;
case METHODTYPE_REPLY:
/* Remember multi-threaded callbacks will have to be handled specially */
[received_reply_rmc_queue_gate lock];
[received_reply_rmc_queue enqueueObject: rmc];
[received_reply_rmc_queue addObject: rmc];
[received_reply_rmc_queue_gate unlock];
break;
case CONNECTION_SHUTDOWN:
@ -1499,8 +1497,10 @@ static int messages_received_count;
id rmc;
[received_request_rmc_queue_gate lock];
while (is_valid && (rmc = [received_request_rmc_queue dequeueObject]))
while (is_valid && ([received_request_rmc_queue count] > 0))
{
rmc = [received_request_rmc_queue objectAtIndex: 0];
[received_request_rmc_queue removeObjectAtIndex: 0];
[received_request_rmc_queue_gate unlock];
[self _handleRmc: rmc];
[received_request_rmc_queue_gate lock];

View file

@ -1290,4 +1290,3 @@ static NSFileManager* defaultManager = nil;
}
@end /* NSFileManager (PrivateMethods) */
@end

View file

@ -28,6 +28,7 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSString.h>
#include <Foundation/NSCoder.h>
#include <netdb.h>
/* #include <libc.h> */
@ -209,6 +210,37 @@ static NSMutableDictionary *_hostCache = nil;
[_hostCacheLock unlock];
}
/* Methods for encoding/decoding */
- (Class) classForPortCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeObject: [self address]];
}
/* GNUstep specific method for more efficient decoding. */
+ (id) newWithCoder: (NSCoder*)aCoder
{
NSString *address = [aCoder decodeObject];
return [NSHost hostWithAddress: address];
}
/* OpenStep method for decoding (not used) */
- (id) initWithCoder: (NSCoder*)aCoder
{
NSString *address;
[super initWithCoder: aCoder];
address = [aCoder decodeObject];
[self dealloc];
return [NSHost hostWithAddress: address];
}
- (BOOL)isEqualToHost:(NSHost *)aHost
{
NSArray* a;

View file

@ -585,15 +585,16 @@ static int debug_run_loop = 0;
- (void) runUntilDate: date forMode: (NSString*)mode
{
volatile double ti;
BOOL mayDoMore = YES;
ti = [date timeIntervalSinceNow];
/* Positive values are in the future. */
while (ti > 0)
while (ti > 0 && mayDoMore == YES)
{
id arp = [NSAutoreleasePool new];
if (debug_run_loop)
printf ("\tNSRunLoop run until date %f seconds from now\n", ti);
[self runMode: mode beforeDate: date];
mayDoMore = [self runMode: mode beforeDate: date];
[arp release];
ti = [date timeIntervalSinceNow];
}