Minor tweaks.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8073 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-11-10 03:01:45 +00:00
parent 543624301e
commit dc77c552c2
4 changed files with 56 additions and 23 deletions

View file

@ -1,3 +1,8 @@
2000-11-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTcpPort.m: Added some locking tweaks for writing data.
* Source/GSString.m: Fix for decoding obsolete string classes.
2000-11-09 Richard Frith-Macdonald <rfm@gnu.org> 2000-11-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPort.m: ([-setDelegate:]) corrected assertion to allow * Source/NSPort.m: ([-setDelegate:]) corrected assertion to allow

View file

@ -2935,8 +2935,9 @@ transmute(ivars self, NSString *aString)
{ {
unsigned count; unsigned count;
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self); RELEASE(self);
self = (id)NSAllocateObject(GSCStringClass, 0, GSObjCZone(self)); self = (id)NSAllocateObject(GSCStringClass, 0, NSDefaultMallocZone());
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0) if (count > 0)
{ {
@ -2965,8 +2966,9 @@ transmute(ivars self, NSString *aString)
{ {
unsigned count; unsigned count;
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self); RELEASE(self);
self = (id)NSAllocateObject(GSMutableStringClass, 0, GSObjCZone(self)); self = (id)NSAllocateObject(GSMutableStringClass, 0, NSDefaultMallocZone());
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0) if (count > 0)
{ {
@ -2995,8 +2997,9 @@ transmute(ivars self, NSString *aString)
{ {
unsigned count; unsigned count;
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self); RELEASE(self);
self = (id)NSAllocateObject(GSUnicodeStringClass, 0, GSObjCZone(self)); self = (id)NSAllocateObject(GSUnicodeStringClass, 0, NSDefaultMallocZone());
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0) if (count > 0)
{ {
@ -3025,8 +3028,9 @@ transmute(ivars self, NSString *aString)
{ {
unsigned count; unsigned count;
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
RELEASE(self); RELEASE(self);
self = (id)NSAllocateObject(GSMutableStringClass, 0, GSObjCZone(self)); self = (id)NSAllocateObject(GSMutableStringClass, 0, NSDefaultMallocZone());
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0) if (count > 0)
{ {

View file

@ -720,7 +720,6 @@ static Class runLoopClass;
NSDebugMLLog(@"GSTcpHandle", @"read %d bytes", res); NSDebugMLLog(@"GSTcpHandle", @"read %d bytes", res);
rLength += res; rLength += res;
while (valid == YES && rLength >= rWant) while (valid == YES && rLength >= rWant)
{ {
switch (rType) switch (rType)
@ -1004,12 +1003,14 @@ static Class runLoopClass;
} }
b = [wData bytes]; b = [wData bytes];
l = [wData length]; l = [wData length];
DO_LOCK(myLock);
res = write(desc, b + wLength, l - wLength); res = write(desc, b + wLength, l - wLength);
if (res < 0) if (res < 0)
{ {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
{ {
NSLog(@"write attempt failed - %s", strerror(errno)); NSLog(@"write attempt failed - %s", strerror(errno));
DO_UNLOCK(myLock);
[self invalidate]; [self invalidate];
return; return;
} }
@ -1056,6 +1057,7 @@ static Class runLoopClass;
} }
} }
} }
DO_UNLOCK(myLock);
} }
} }
} }

View file

@ -328,11 +328,12 @@ usage(const char *program)
printf(" -m - Messaging test\n"); printf(" -m - Messaging test\n");
printf(" -l - Loop test\n"); printf(" -l - Loop test\n");
printf(" -o - Objects test\n"); printf(" -o - Objects test\n");
printf(" -c - Connect test\n");
} }
typedef enum { typedef enum {
NO_TEST, TYPE_TEST, BENCHMARK_TEST, MESSAGE_TEST, NO_TEST, TYPE_TEST, BENCHMARK_TEST, MESSAGE_TEST,
LOOP_TEST, OBJECT_TEST LOOP_TEST, OBJECT_TEST, CONNECT_TEST
} test_t; } test_t;
int main (int argc, char *argv[], char **env) int main (int argc, char *argv[], char **env)
@ -340,6 +341,7 @@ int main (int argc, char *argv[], char **env)
int c, debug, stats; int c, debug, stats;
test_t type_test; test_t type_test;
id cobj, prx; id cobj, prx;
unsigned connect_attempts;
NSAutoreleasePool *arp; NSAutoreleasePool *arp;
Auth *auth; Auth *auth;
#ifndef __MINGW__ #ifndef __MINGW__
@ -355,7 +357,7 @@ int main (int argc, char *argv[], char **env)
debug = 0; debug = 0;
type_test = 0; type_test = 0;
stats = 0; stats = 0;
while ((c = getopt(argc, argv, "hdtbmslo")) != EOF) while ((c = getopt(argc, argv, "hdtbmsloc")) != EOF)
switch (c) switch (c)
{ {
case 'd': case 'd':
@ -379,6 +381,9 @@ int main (int argc, char *argv[], char **env)
case 'o': case 'o':
type_test = OBJECT_TEST; type_test = OBJECT_TEST;
break; break;
case 'c':
type_test = CONNECT_TEST;
break;
case 'h': case 'h':
usage(argv[0]); usage(argv[0]);
exit(0); exit(0);
@ -398,6 +403,13 @@ int main (int argc, char *argv[], char **env)
//[NSPort setDebug: 10]; //[NSPort setDebug: 10];
} }
if (type_test == CONNECT_TEST)
connect_attempts = 100000;
else
connect_attempts = 1;
while (connect_attempts-- > 0)
{
if (optind < argc) if (optind < argc)
{ {
if (optind+1 < argc) if (optind+1 < argc)
@ -410,14 +422,24 @@ int main (int argc, char *argv[], char **env)
host:[NSString stringWithCString:argv[optind]]]; host:[NSString stringWithCString:argv[optind]]];
} }
else else
prx = [NSConnection rootProxyForConnectionWithRegisteredName:@"test2server" prx = [NSConnection rootProxyForConnectionWithRegisteredName:
@"test2server"
host:nil]; host:nil];
if (prx == nil) if (prx == nil)
{ {
printf("ERROR: Failed to connect to server\n"); printf("ERROR: Failed to connect to server\n");
return -1; return -1;
} }
if (type_test == CONNECT_TEST)
{
NSLog(@"Made connection\n");
if (connect_attempts > 0)
{
RELEASE(arp);
arp = [NSAutoreleasePool new];
}
}
}
cobj = [prx connectionForProxy]; cobj = [prx connectionForProxy];
[cobj setDelegate:auth]; [cobj setDelegate:auth];