ObjFW  Diff

Differences From Artifact [14251acfde]:

To Artifact [aae6155a72]:

  • File src/OFLHADecompressingStream.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: 12524) [annotate] [blame] [check-ins using] [more...]


119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
	}

	return self;
}

- (void)dealloc
{

	[self close];

	if (_codeLenTree != NULL)
		of_huffman_tree_release(_codeLenTree);
	if (_litLenTree != NULL)
		of_huffman_tree_release(_litLenTree);
	if (_distTree != NULL)
		of_huffman_tree_release(_distTree);







>
|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
	}

	return self;
}

- (void)dealloc
{
	if (_stream != nil)
		[self close];

	if (_codeLenTree != NULL)
		of_huffman_tree_release(_codeLenTree);
	if (_litLenTree != NULL)
		of_huffman_tree_release(_litLenTree);
	if (_distTree != NULL)
		of_huffman_tree_release(_distTree);
512
513
514
515
516
517
518



519
520
521
522
523
524
525
526
527
528
529
530
{
	return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer ||
	    _bufferLength - _bufferIndex > 0);
}

- (void)close
{



	/* Give back our buffer to the stream, in case it's shared */
	[_stream unreadFromBuffer: _buffer + _bufferIndex
			   length: _bufferLength - _bufferIndex];
	_bytesConsumed -= _bufferLength - _bufferIndex;
	_bufferIndex = _bufferLength = 0;

	[_stream release];
	_stream = nil;

	[super close];
}
@end







>
>
>












513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
{
	return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer ||
	    _bufferLength - _bufferIndex > 0);
}

- (void)close
{
	if (_stream == nil)
		@throw [OFNotOpenException exceptionWithObject: self];

	/* Give back our buffer to the stream, in case it's shared */
	[_stream unreadFromBuffer: _buffer + _bufferIndex
			   length: _bufferLength - _bufferIndex];
	_bytesConsumed -= _bufferLength - _bufferIndex;
	_bufferIndex = _bufferLength = 0;

	[_stream release];
	_stream = nil;

	[super close];
}
@end