Ben Copsey

Add lock around progress updates and cancel to iphone attempting to access zombie data

... ... @@ -112,6 +112,9 @@
//This lock will block the request until the delegate supplies authentication info
NSConditionLock *authenticationLock;
//This lock prevents the operation from being cancelled while it is trying to update the progress, and vice versa
NSLock *progressLock;
//Called on the delegate when the request completes successfully
SEL didFinishSelector;
... ...
... ... @@ -85,6 +85,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
[domain release];
[authenticationRealm release];
[url release];
[progressLock release];
[authenticationLock release];
[lastActivityTime release];
[responseCookies release];
... ... @@ -118,6 +119,13 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
return complete;
}
- (void)cancel
{
[progressLock lock];
[super cancel];
[progressLock unlock];
}
- (int)totalBytesRead
{
return totalBytesRead;
... ... @@ -207,6 +215,9 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
{
CFRunLoopAddCommonMode(CFRunLoopGetCurrent(),ASIHTTPRequestRunMode);
[progressLock release];
progressLock = [[NSLock alloc] init];
[authenticationLock release];
authenticationLock = [[NSConditionLock alloc] initWithCondition:1];
... ... @@ -321,8 +332,14 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
- (void)updateProgressIndicators
{
[progressLock lock];
if ([self isCancelled]) {
[progressLock unlock];
return;
}
[self updateUploadProgress];
[self updateDownloadProgress];
[progressLock unlock];
}
... ...
... ... @@ -30,15 +30,17 @@
<object class="IBUILabel" id="602749642">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 20}, {280, 105}}</string>
<string key="NSFrame">{{20, 20}, {280, 144}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string type="base64-UTF8" key="IBUIText">RGVtb25zdHJhdGVzIGZldGNoaW5nIGEgd2ViIHBhZ2Ugc3luY2hyb25vdXNseSwgdGhlIEhUTUwgc291
cmNlIHdpbGwgYXBwZWFyIGluIHRoZSBib3ggYmVsb3cgd2hlbiB0aGUgZG93bmxvYWQgaXMgY29tcGxl
dGUuICBJbiByZWFsIHdvcmxkIHNpdHVhdGlvbnMsIHlvdSdkIGJlIG1vcmUgbGlrZWx5IHRvIHJ1biB0
aGlzIGluIGEgdGhyZWFkLg</string>
dGUuICBUaGUgaW50ZXJmYWNlIHdpbGwgbG9jayB1cCB3aGVuIHlvdSBwcmVzcyB0aGlzIGJ1dHRvbiB1
bnRpbCB0aGUgb3BlcmF0aW9uIHRpbWVzIG91dCBvciBzdWNjZWVkcy4gSW4gcmVhbCB3b3JsZCBzaXR1
YXRpb25zLCB5b3UnZCBiZSBtb3JlIGxpa2VseSB0byB1c2Ugc3luY2hyb25vdXMgcmVxdWVzdHMgaW4g
YSB0aHJlYWQuA</string>
<object class="NSFont" key="IBUIFont" id="467718481">
<string key="NSName">Helvetica</string>
<double key="NSSize">1.400000e+01</double>
... ... @@ -56,7 +58,7 @@ aGlzIGluIGEgdGhyZWFkLg</string>
<object class="IBUIButton" id="963091686">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 133}, {72, 37}}</string>
<string key="NSFrame">{{20, 172}, {72, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
... ... @@ -84,7 +86,7 @@ aGlzIGluIGEgdGhyZWFkLg</string>
<object class="IBUITextView" id="251778509">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 184}, {280, 187}}</string>
<string key="NSFrame">{{20, 217}, {280, 154}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
... ...