Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ben Copsey
2010-11-10 14:15:31 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a5af299396cb2bd174d5d3658776206452832b8e
a5af2993
1 parent
341fb517
Set clear stream client when unscheduling the readstream, and set it again when scheduling
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
21 deletions
Classes/ASIHTTPRequest.m
Classes/ASIHTTPRequest.m
View file @
a5af299
...
...
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-13
2
2010-11-10"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-13
3
2010-11-10"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
@@ -3355,33 +3355,15 @@ static NSOperationQueue *sharedQueue = nil;
#pragma mark managing the read stream
-
(
void
)
destroyReadStream
{
if
([
self
readStream
])
{
CFReadStreamSetClient
((
CFReadStreamRef
)[
self
readStream
],
kCFStreamEventNone
,
NULL
,
NULL
);
[
connectionsLock
lock
];
if
([
self
readStreamIsScheduled
])
{
runningRequestCount
--
;
if
(
shouldUpdateNetworkActivityIndicator
&&
runningRequestCount
==
0
)
{
// This call will wait half a second before turning off the indicator
// This can prevent flicker when you have a single request finish and then immediately start another request
// We run this on the main thread because we have no guarantee this thread will have a runloop in 0.5 seconds time
// We don't bother the cancel this call if we start a new request, because we'll check if requests are running before we hide it
[[
self
class
]
performSelectorOnMainThread
:
@selector
(
hideNetworkActivityIndicatorAfterDelay
)
withObject
:
nil
waitUntilDone
:
[
NSThread
isMainThread
]];
}
}
[
self
setReadStreamIsScheduled
:
NO
];
[
self
unscheduleReadStream
];
if
(
!
[
self
connectionCanBeReused
])
{
[[
self
readStream
]
removeFromRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:[
self
runLoopMode
]];
[[
self
readStream
]
close
];
}
[
self
setReadStream
:
nil
];
[
connectionsLock
unlock
];
}
}
...
...
@@ -3398,6 +3380,8 @@ static NSOperationQueue *sharedQueue = nil;
// Reset the timeout
[
self
setLastActivityTime
:[
NSDate
date
]];
CFStreamClientContext
ctxt
=
{
0
,
self
,
NULL
,
NULL
,
NULL
};
CFReadStreamSetClient
((
CFReadStreamRef
)[
self
readStream
],
kNetworkEvents
,
ReadStreamClientCallBack
,
&
ctxt
);
[[
self
readStream
]
scheduleInRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:[
self
runLoopMode
]];
[
self
setReadStreamIsScheduled
:
YES
];
}
...
...
@@ -3411,11 +3395,15 @@ static NSOperationQueue *sharedQueue = nil;
[
connectionsLock
lock
];
runningRequestCount
--
;
if
(
shouldUpdateNetworkActivityIndicator
&&
runningRequestCount
==
0
)
{
// See comment in destroyReadStream for more info
// This call will wait half a second before turning off the indicator
// This can prevent flicker when you have a single request finish and then immediately start another request
// We run this on the main thread because we have no guarantee this thread will have a runloop in 0.5 seconds time
// We don't bother the cancel this call if we start a new request, because we'll check if requests are running before we hide it
[[
self
class
]
performSelectorOnMainThread
:
@selector
(
hideNetworkActivityIndicatorAfterDelay
)
withObject
:
nil
waitUntilDone
:
[
NSThread
isMainThread
]];
}
[
connectionsLock
unlock
];
CFReadStreamSetClient
((
CFReadStreamRef
)[
self
readStream
],
kCFStreamEventNone
,
NULL
,
NULL
);
[[
self
readStream
]
removeFromRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:[
self
runLoopMode
]];
[
self
setReadStreamIsScheduled
:
NO
];
}
...
...
Please
register
or
login
to post a comment