Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some correctness tweaks to TDSocketChangeTracker

A futile attempt to address truncated feeds (#241); but I think these are
good changes to make anyway even if they didn't help that.
  • Loading branch information...
commit 34ddf4ef3b472549e5f554b0c126b69c3502a698 1 parent f3788a0
@snej snej authored
Showing with 9 additions and 14 deletions.
  1. +9 −14 Source/ChangeTracker/TDSocketChangeTracker.m
View
23 Source/ChangeTracker/TDSocketChangeTracker.m
@@ -27,7 +27,7 @@
#define kMaxRetries 6
#define kInitialRetryDelay 0.2
-#define kReadLength 8192u
+#define kReadLength 4096u
@implementation TDSocketChangeTracker
@@ -126,6 +126,7 @@ - (BOOL) start {
- (void) clearConnection {
[_trackingInput close];
+ [_trackingInput removeFromRunLoop: [NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes];
_trackingInput = nil;
_inputBuffer = nil;
_changeBuffer = nil;
@@ -185,7 +186,7 @@ - (NSURLCredential*) credentialForAuthHeader: (NSString*)authHeader {
// Basic & digest auth: http://www.ietf.org/rfc/rfc2617.txt
if (!authHeader)
return nil;
-
+
// Get the auth type:
if ([authHeader hasPrefix: @"Basic"])
authenticationMethod = NSURLAuthenticationMethodHTTPBasic;
@@ -391,18 +392,12 @@ - (void) readFromInput {
Assert(_inputAvailable);
_inputAvailable = false;
- uint8_t* buffer;
- NSUInteger bufferLength;
- NSInteger bytesRead;
- if ([_trackingInput getBuffer: &buffer length: &bufferLength]) {
- [_inputBuffer appendBytes: buffer length: bufferLength];
- bytesRead = bufferLength;
- } else {
- uint8_t buffer[kReadLength];
- bytesRead = [_trackingInput read: buffer maxLength: sizeof(buffer)];
- if (bytesRead > 0)
- [_inputBuffer appendBytes: buffer length: bytesRead];
- }
+ uint8_t buffer[kReadLength];
+ NSInteger bytesRead = [_trackingInput read: buffer maxLength: sizeof(buffer)];
+ if (bytesRead > 0)
+ [_inputBuffer appendBytes: buffer length: bytesRead];
+ else
+ Warn(@"%@: input stream read returned %ld", self, (long)bytesRead); // should never happen
LogTo(ChangeTracker, @"%@: read %ld bytes", self, (long)bytesRead);
if (_mode == kContinuous)

0 comments on commit 34ddf4e

Please sign in to comment.
Something went wrong with that request. Please try again.