ObjFW  Diff

Differences From Artifact [4ead6e5d4b]:

To Artifact [730550a384]:

  • File src/OFStdIOStream.m — part of check-in [3b43d51006] at 2020-01-14 00:16:04 on branch trunk — More consistent -[close] behavior

    This means refusing to close twice, calling -[close] from -[dealloc] and
    not calling -[cancelAsyncRequests].

    Calling -[cancelAsyncRequests] in -[close] is too dangerous, as -[close]
    gets called by -[dealloc]: If the queue is the last reference to the
    object, at the point where -[cancelAsyncRequests] removes it from the
    queue, the object will start to deallocate and call into
    -[cancelAsyncRequests] again, which is still in the middle of removing
    it and now finds itself with an inconsistent state. (user: js, size: 7419) [annotate] [blame] [check-ins using] [more...]


174
175
176
177
178
179
180





181

182
183
184
185
186
187
188
174
175
176
177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







+
+
+
+
+
-
+








	return self;
}
#endif

- (void)dealloc
{
#ifndef OF_AMIGAOS
	if (_fd != -1)
#else
	if (_handle != 0)
#endif
	[self close];
		[self close];

	[super dealloc];
}

- (bool)lowlevelIsAtEndOfStream
{
#ifndef OF_AMIGAOS
297
298
299
300
301
302
303
304
305


306

307
308



309

310
311
312
313
314
315
316
302
303
304
305
306
307
308


309
310
311
312
313
314
315
316
317

318
319
320
321
322
323
324
325







-
-
+
+

+


+
+
+
-
+







	return _fd;
}
#endif

- (void)close
{
#ifndef OF_AMIGAOS
	if (_fd != -1)
		close(_fd);
	if (_fd == -1)
		@throw [OFNotOpenException exceptionWithObject: self];

	close(_fd);
	_fd = -1;
#else
	if (_handle == 0)
		@throw [OFNotOpenException exceptionWithObject: self];

	if (_closable && _handle != 0)
	if (_closable)
		Close(_handle);

	_handle = 0;
#endif

	[super close];
}