win32 standard io fixup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39454 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-03-04 18:06:01 +00:00
parent 4f9d5c0982
commit d3aab9bc45
2 changed files with 42 additions and 30 deletions

View file

@ -96,9 +96,9 @@
#define NETBUF_SIZE (1024 * 16) #define NETBUF_SIZE (1024 * 16)
#define READ_SIZE NETBUF_SIZE*10 #define READ_SIZE NETBUF_SIZE*10
static GSFileHandle* fh_stdin = nil; static GSFileHandle *fh_stdin = nil;
static GSFileHandle* fh_stdout = nil; static GSFileHandle *fh_stdout = nil;
static GSFileHandle* fh_stderr = nil; static GSFileHandle *fh_stderr = nil;
@interface GSTcpTune : NSObject @interface GSTcpTune : NSObject
- (int) delay; - (int) delay;

View file

@ -70,9 +70,9 @@
#define NETBUF_SIZE 4096 #define NETBUF_SIZE 4096
#define READ_SIZE NETBUF_SIZE*10 #define READ_SIZE NETBUF_SIZE*10
static GSFileHandle* fh_stdin = nil; static GSFileHandle *fh_stdin = nil;
static GSFileHandle* fh_stdout = nil; static GSFileHandle *fh_stdout = nil;
static GSFileHandle* fh_stderr = nil; static GSFileHandle *fh_stderr = nil;
// Key to info dictionary for operation mode. // Key to info dictionary for operation mode.
static NSString* NotificationKey = @"NSFileHandleNotificationKey"; static NSString* NotificationKey = @"NSFileHandleNotificationKey";
@ -239,6 +239,24 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
- (void) dealloc - (void) dealloc
{ {
if (self == fh_stdin)
{
RETAIN(self);
[NSException raise: NSGenericException
format: @"Attempt to deallocate standard input handle"];
}
if (self == fh_stdout)
{
RETAIN(self);
[NSException raise: NSGenericException
format: @"Attempt to deallocate standard output handle"];
}
if (self == fh_stderr)
{
RETAIN(self);
[NSException raise: NSGenericException
format: @"Attempt to deallocate standard error handle"];
}
RELEASE(address); RELEASE(address);
RELEASE(service); RELEASE(service);
RELEASE(protocol); RELEASE(protocol);
@ -1022,18 +1040,16 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (fh_stderr != nil) if (fh_stderr != nil)
{ {
RETAIN(fh_stderr); ASSIGN(self, fh_stderr);
DESTROY(self);
} }
else else
{ {
self = [self initWithFileDescriptor: 2 closeOnDealloc: NO]; self = [self initWithFileDescriptor: 2 closeOnDealloc: NO];
fh_stderr = self; ASSIGN(fh_stderr, self);
} if (self)
self = fh_stderr; {
if (self) readOK = NO;
{ }
readOK = NO;
} }
return self; return self;
} }
@ -1042,18 +1058,16 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (fh_stdin != nil) if (fh_stdin != nil)
{ {
RETAIN(fh_stdin); ASSIGN(self, fh_stdin);
DESTROY(self);
} }
else else
{ {
self = [self initWithFileDescriptor: 0 closeOnDealloc: NO]; self = [self initWithFileDescriptor: 0 closeOnDealloc: NO];
fh_stdin = self; ASSIGN(fh_stdin, self);
} if (self)
self = fh_stdin; {
if (self) writeOK = NO;
{ }
writeOK = NO;
} }
return self; return self;
} }
@ -1062,18 +1076,16 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (fh_stdout != nil) if (fh_stdout != nil)
{ {
RETAIN(fh_stdout); ASSIGN(fh_stdout, self);
DESTROY(self);
} }
else else
{ {
self = [self initWithFileDescriptor: 1 closeOnDealloc: NO]; self = [self initWithFileDescriptor: 1 closeOnDealloc: NO];
fh_stdout = self; ASSIGN(fh_stdout, self);
} if (self)
self = fh_stdout; {
if (self) readOK = NO;
{ }
readOK = NO;
} }
return self; return self;
} }