Various fixes to Services Kit
* Remove useless dummy protocol loop in UrlRequest * Stop HTTP requests before deleting the socket and other things the loop may still be using * Deletion of items from the authentication map wasn't working * Remove some debug traces
This commit is contained in:
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
protected:
|
||||
static int32 _ThreadEntry(void* arg);
|
||||
virtual status_t _ProtocolLoop();
|
||||
virtual status_t _ProtocolLoop() = 0;
|
||||
virtual void _EmitDebug(BUrlProtocolDebugMessage type,
|
||||
const char* format, ...);
|
||||
protected:
|
||||
|
||||
@@ -57,6 +57,8 @@ BHttpRequest::BHttpRequest(const BUrl& url, bool ssl, const char* protocolName,
|
||||
|
||||
BHttpRequest::~BHttpRequest()
|
||||
{
|
||||
Stop();
|
||||
|
||||
delete fSocket;
|
||||
|
||||
delete fOptInputData;
|
||||
@@ -550,7 +552,6 @@ BHttpRequest::_MakeRequest()
|
||||
ssize_t bytesTotal = 0;
|
||||
char* inputTempBuffer = NULL;
|
||||
ssize_t chunkSize = -1;
|
||||
fQuit = false;
|
||||
|
||||
while (!fQuit && !(receiveEnd && parseEnd)) {
|
||||
if (!receiveEnd) {
|
||||
@@ -560,8 +561,7 @@ BHttpRequest::_MakeRequest()
|
||||
|
||||
if (bytesRead < 0) {
|
||||
readError = true;
|
||||
fQuit = true;
|
||||
continue;
|
||||
break;
|
||||
} else if (bytesRead == 0)
|
||||
receiveEnd = true;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ BUrlContext::BUrlContext()
|
||||
fAuthenticationMap(NULL)
|
||||
{
|
||||
fAuthenticationMap = new(std::nothrow) BHttpAuthenticationMap();
|
||||
if(!fAuthenticationMap)
|
||||
return;
|
||||
|
||||
// This is the default authentication, used when nothing else is found.
|
||||
// The empty string used as a key will match all the domain strings, once
|
||||
// we have removed all components.
|
||||
@@ -35,7 +34,7 @@ BUrlContext::~BUrlContext()
|
||||
BHttpAuthenticationMap::Iterator iterator =
|
||||
fAuthenticationMap->GetIterator();
|
||||
while(iterator.HasNext())
|
||||
delete iterator.Remove().value;
|
||||
delete *iterator.NextValue();
|
||||
|
||||
delete fAuthenticationMap;
|
||||
}
|
||||
@@ -59,10 +58,15 @@ BUrlContext::AddAuthentication(const BUrl& url,
|
||||
domain += url.Path();
|
||||
BPrivate::HashString hostHash(domain.String(), domain.Length());
|
||||
|
||||
delete fAuthenticationMap->Get(hostHash);
|
||||
// Make sure we don't leak memory by overriding a previous
|
||||
// authentication for the same domain.
|
||||
fAuthenticationMap->Put(hostHash, authentication);
|
||||
BHttpAuthentication* previous = fAuthenticationMap->Get(hostHash);
|
||||
|
||||
// Make sure we don't leak memory by overriding a previous
|
||||
// authentication for the same domain.
|
||||
if(authentication != previous) {
|
||||
fAuthenticationMap->Put(hostHash, authentication);
|
||||
// replaces the old one
|
||||
delete previous;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,11 +29,8 @@ BUrlProtocolRoster::MakeRequest(const BUrl& url,
|
||||
return new(std::nothrow) BHttpRequest(url, true, "HTTPS", listener,
|
||||
context);
|
||||
} else if (url.Protocol() == "file") {
|
||||
puts("*** FILE URL");
|
||||
return new(std::nothrow) BFileRequest(url, listener, context);
|
||||
}
|
||||
|
||||
puts("*** UNKNOWN protocol");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -231,17 +231,6 @@ BUrlRequest::_ThreadEntry(void* arg)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BUrlRequest::_ProtocolLoop()
|
||||
{
|
||||
// Dummy _ProtocolLoop
|
||||
while (!fQuit)
|
||||
snooze(1000);
|
||||
|
||||
return B_PROT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BUrlRequest::_EmitDebug(BUrlProtocolDebugMessage type,
|
||||
const char* format, ...)
|
||||
|
||||
Reference in New Issue
Block a user