ObjFW  Check-in [cea3f2133d]

Overview
Comment:Cancel async requests in OFStreamSocket instead

Closing them in OFStream would result in always canceling them after
closing the socket due to the -[close] chaining - which could never
work.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cea3f2133d77f336e4ab3e3443f8199ad742bd0fb2c5b4b3d9d0bbd22288eaab
User & Date: js on 2020-01-12 16:22:49
Other Links: manifest | tags
Context
2020-01-12
17:37
OFHTTPClient: Always keep the underlying socket check-in: b4810363ea user: js tags: trunk
16:22
Cancel async requests in OFStreamSocket instead check-in: cea3f2133d user: js tags: trunk
2020-01-07
22:59
OFKernelEventObserver: Fix read buffers, select() check-in: 23ff70bec4 user: js tags: trunk
Changes

Modified src/OFStream.m from [2c231bfb94] to [749b5fd798].

1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
	[self freeMemory: _readBufferMemory];
	_readBuffer = _readBufferMemory = readBuffer;
	_readBufferLength += length;
}

- (void)close
{
#ifdef OF_HAVE_SOCKETS
	[self cancelAsyncRequests];
#endif

	[self freeMemory: _readBufferMemory];
	_readBuffer = _readBufferMemory = NULL;
	_readBufferLength = 0;

	[self freeMemory: _writeBuffer];
	_writeBuffer = NULL;
	_writeBufferLength = 0;
	_writeBuffered = false;

	_waitingForDelimiter = false;
}
@end







<
<
<
<












1905
1906
1907
1908
1909
1910
1911




1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
	[self freeMemory: _readBufferMemory];
	_readBuffer = _readBufferMemory = readBuffer;
	_readBufferLength += length;
}

- (void)close
{




	[self freeMemory: _readBufferMemory];
	_readBuffer = _readBufferMemory = NULL;
	_readBufferLength = 0;

	[self freeMemory: _writeBuffer];
	_writeBuffer = NULL;
	_writeBufferLength = 0;
	_writeBuffered = false;

	_waitingForDelimiter = false;
}
@end

Modified src/OFStreamSocket.m from [bc21bce60d] to [6026b8fcfc].

172
173
174
175
176
177
178




179
180
181
182
183
184
185
#endif
}

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





	closesocket(_socket);
	_socket = INVALID_SOCKET;

	_atEndOfStream = false;

	[super close];







>
>
>
>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#endif
}

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

#ifdef OF_HAVE_SOCKETS
	[self cancelAsyncRequests];
#endif

	closesocket(_socket);
	_socket = INVALID_SOCKET;

	_atEndOfStream = false;

	[super close];