ObjFW  Check-in [321f4c67a4]

Overview
Comment:OFDNSResolver: Retry with TCP if TC is set
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 321f4c67a4eb7439970de7435b557551b0346529654ca12ca3e51600ad7b8564
User & Date: js on 2020-04-18 20:43:08
Other Links: manifest | tags
Context
2020-04-19
10:02
Clean up which exception is used when a little check-in: 3356b9940c user: js tags: trunk
2020-04-18
20:43
OFDNSResolver: Retry with TCP if TC is set check-in: 321f4c67a4 user: js tags: trunk
19:36
OFDNSResolver: Add support for queries over TCP check-in: 45452562b7 user: js tags: trunk
Changes

Modified src/OFDNSResolver.m from [6d3a9fb443] to [ff93d36ccb].

711
712
713
714
715
716
717



718
719
720
721
722
723
724
}

- (void)of_sendQueryForContext: (OFDNSResolverContext *)context
		   runLoopMode: (of_run_loop_mode_t)runLoopMode
{
	OFUDPSocket *sock;
	OFString *nameServer;




	[context->_cancelTimer invalidate];
	[context->_cancelTimer release];
	context->_cancelTimer = nil;
	context->_cancelTimer = [[OFTimer alloc]
	    initWithFireDate: [OFDate dateWithTimeIntervalSinceNow:
				  context->_settings->_timeout]







>
>
>







711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
}

- (void)of_sendQueryForContext: (OFDNSResolverContext *)context
		   runLoopMode: (of_run_loop_mode_t)runLoopMode
{
	OFUDPSocket *sock;
	OFString *nameServer;

	[_queries setObject: context
		     forKey: context->_ID];

	[context->_cancelTimer invalidate];
	[context->_cancelTimer release];
	context->_cancelTimer = nil;
	context->_cancelTimer = [[OFTimer alloc]
	    initWithFireDate: [OFDate dateWithTimeIntervalSinceNow:
				  context->_settings->_timeout]
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
		@throw [OFOutOfRangeException exception];

	context = [[[OFDNSResolverContext alloc]
	    initWithQuery: query
		       ID: ID
		 settings: _settings
		 delegate: delegate] autorelease];
	[_queries setObject: context
		     forKey: ID];

	[self of_sendQueryForContext: context
			 runLoopMode: runLoopMode];

	objc_autoreleasePoolPop(pool);
}

- (void)of_contextTimedOut: (OFDNSResolverContext *)context







<
<
<







820
821
822
823
824
825
826



827
828
829
830
831
832
833
		@throw [OFOutOfRangeException exception];

	context = [[[OFDNSResolverContext alloc]
	    initWithQuery: query
		       ID: ID
		 settings: _settings
		 delegate: delegate] autorelease];



	[self of_sendQueryForContext: context
			 runLoopMode: runLoopMode];

	objc_autoreleasePoolPop(pool);
}

- (void)of_contextTimedOut: (OFDNSResolverContext *)context
942
943
944
945
946
947
948
949



950







951
952
953
954
955
956
957
			@throw [OFInvalidServerReplyException exception];

		/* Opcode */
		if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78))
			@throw [OFInvalidServerReplyException exception];

		/* TC */
		if (buffer[2] & 0x02)



			@throw [OFTruncatedDataException exception];








		/* RCODE */
		switch (buffer[3] & 0x0F) {
		case 0:
			break;
		case 1:
			error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT;







|
>
>
>
|
>
>
>
>
>
>
>







942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
			@throw [OFInvalidServerReplyException exception];

		/* Opcode */
		if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78))
			@throw [OFInvalidServerReplyException exception];

		/* TC */
		if (buffer[2] & 0x02) {
			of_run_loop_mode_t runLoopMode;

			if (context->_settings->_usesTCP)
				@throw [OFTruncatedDataException exception];

			context->_settings->_usesTCP = true;
			runLoopMode = [OFRunLoop currentRunLoop].currentMode;
			[self of_sendQueryForContext: context
					 runLoopMode: runLoopMode];
			return false;
		}

		/* RCODE */
		switch (buffer[3] & 0x0F) {
		case 0:
			break;
		case 1:
			error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT;